Please share more ideas to get software version from bash command and use it as variable later.

 su --version
su (GNU coreutils) 5.97
Copyright etc.

and create variable of the result of it. Something like I tried below.

su --version >/tmp/temp.txt

if [ -f /tmp/temp.txt ]; then
    elv=`cat /tmp/temp.txt | gawk 'BEGIN {FS="(GNU coreutils)"} {print $2}' | gawk 'BEGIN {FS="."} {print $1}'`
    #Version String. Just a shortcut to be used later
    els=el$elv
else
    echo "Unable to determine version. I can't continue"
    exit 1
fi

if [ `rpm -qa | egrep -c -i "^mysql-"` -gt 0 ]; then
cat << EOF

It appears that the distro-supplied version of MySQL is at least partially installed,
or a prior installation attempt failed.

Please remove these packages, as well as their dependencies (often postfix), and then
retry this script:

$(rpm -qa | egrep -i "^mysql-")

EOF
exit 1
fi
0

There are 0 best solutions below