I'm trying to grep for a instance "test" in /etc/oratab. But wanted to display only the line that doesn't begin with a comment. Below are the lines from /etc/oratab file:
#test:/u01/appl/oracle/test/db/tech_st/12.1.0.2:N
test:/b001/app/oracle/testrac/db/tech_st/12.1.0.2:N # line added by Agent
This is how I'm trying to get the details I'm interested in (placed the below in a shell script:
DB_NAME=test
env_var=`cat /etc/oratab |grep $DB_NAME |grep -v '#' |cut -d":" -f 2`
echo $env_var
The problem here is, as the 2nd line also has a comment at its end, it is also being ignored.
Please help.
Regards, RA