To extract substring between two character: Shell Script
var1='mysql-'
var2='-linux'
mysqlFromWhichCommand=/usr/local/mysql-5.1.38-linux-i686-icc-glibc23/bin/mysql
versionMysql=`echo "$mysqlFromWhichCommand" | sed -e "s/.*${v1}//;s/${v2}.*//"``
echo "MySql version: $versionMysql"
var2='-linux'
mysqlFromWhichCommand=/usr/local/mysql-5.1.38-linux-i686-icc-glibc23/bin/mysql
versionMysql=`echo "$mysqlFromWhichCommand" | sed -e "s/.*${v1}//;s/${v2}.*//"``
echo "MySql version: $versionMysql"
Comments