You can get version form lsb_release command and then check if major version is less or equal -le to 18. If lsb_release is not avaiable in a system then just cat /etc/os-release and grep from it what is needed.
#!/bin/bash
OS_VER=$(lsb_release -sr | cut -d'.' -f1)
if [[ $OS_VER -le 18 ]]; then
echo "command 1"
else
echo "command 2"
fi
2
Answers
You can get version form lsb_release command and then check if major version is less or equal
-le
to 18. Iflsb_release
is not avaiable in a system then justcat /etc/os-release
and grep from it what is needed.You can get the version of OS from any of these two file:
Then have an if/else command accordingly to check the version.