extract DB version from oratab

My oratab has the following contents

RMD10203:/u01/app/oracle/product/10.2.0RMD10203:Y
RMDIDEVL:/u01/app/oracle/product/11.1.0RMDIDEVL:Y
RMDIDES:/u01/app/oracle/product/11.1.0RMDIDES:Y

I have a script for which I pass the oracle sid as the parameter
I need to extract the version of the oracle home from the oratab.
I have tried
grep $ORACLE_SID /var/opt/oracle/oratab|grep -v \# |cut -d/ -f6|awk -F":" {'print $1'}
and get "11.1.0RMDIDES" as the output of the command, how do I just get the version like 11.1.0 as the output

Thanks in advance,AK

You could try:

sed -n "s#${ORACLE_SID}.*/\(.*\)${ORACLE_SID}.*#\1#p" /var/opt/oracle/oratab

or shorter, but not as exact:

sed -n "s#.*/\(.*\)${ORACLE_SID}.*#\1#p" /var/opt/oracle/oratab

IN Just changing your code you can change your -F":" -F"R" so you would have

grep $ORACLE_SID /var/opt/oracle/oratab|grep -v \# |cut -d/ -f6|awk -F"R" {'print $1'}

Or you can use Perl -

grep $ORACLE_SID /var/opt/oracle/oratab | perl -lne '/.*\/([\d.]+)/ && print $1'

tyler_durden

$ grep $ORACLE_SID /var/opt/oracle/oratab|sed 's#.*\([0-9][0-9]\.[0-9]\.[0-9]\).*#\1#'
10.2.0
11.1.0
11.1.0

another way..

-bash-3.2$ grep -o "[0-9]\{2\}.[0-9].[0-9]" file
10.2.0
11.1.0
11.1.0

Thnx guys, solved my problem