Database Administration (MOSC)

MOSC Banner

grep variable to get sid name

edited Feb 19, 2016 4:00AM in Database Administration (MOSC) 2 commentsAnswered

Hello,

I am using below code :

Code:

export ORAR=orp712z.int.thomsonreuters.com
if echo $ORAR|grep -i "_"
then
ORACLE_SID1= echo $ORAR|cut -f2 -d "_"
echo $ORACLE_SID1
ORACLE_SID=fgrep "$ORACLE_SID1" /etc/oratab|cut -f1 -d ":"
else
ORACLE_SID1= echo $ORAR|cut -f1 -d "."
echo $ORACLE_SID1
ORACLE_SID=fgrep "$ORACLE_SID1" /etc/oratab|cut -f1 -d ":"
echo $ORACLE_SID
fi

Code:

c643upetcmdr {/home/oracle}: cat /etc/oratab
orp709z1:/u01/app/oracle/product/11.2.0.4/db:N
orp710z1:/u01/app/oracle/product/11.2.0.4/db:N
orp712z1:/u01/app/oracle/product/11.2.0.4/db:N
orp713z1:/u01/app/oracle/product/11.2.0.4/db:N

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center