Hi,
I have a environmental variables,
ORACLE_HOME=/u01/oracle/ORCL/db/tech/10.2.0
ORACLE_SID=ORCL
Now I need to create a variable and need to extract some part from ORACLE_HOME. I need to get the path from ORACLE_HOME till ORACLE_SID as /u01/oracle/ORCL. I may need to check also the first occurance of ORCL in the whole path.
Can anybody suggest the best way to do it nawk or cut or substing.
Please advice.
Thanks and Regards,
Sreejit
bakunin
September 30, 2009, 9:46am
2
ORACLE_HOME=/u01/oracle/ORCL/db/tech/10.2.0
ORACLE_SID=ORCL
echo ${ORACLE_HOME##*${ORACLE_SID}}
echo ${ORACLE_HOME%%${ORACLE_SID}*}
I hope this helps.
bakunin
You can do it with shell parameter expansion:
echo ${ORACLE_HOME%%/$ORACLE_SID*}
Thanks all..It was really quick...
I found this one good, echo ${ORACLE_HOME%%/$ORACLE_SID*}
Can you please explain what it does. Is it removing or cut the $ORACLE_SID from $ORACLE_HOME
Regards,
SReejit
sreejitnair123:
Thanks all..It was really quick...
I found this one good, echo ${ORACLE_HOME%%/$ORACLE_SID*}
Can you please explain what it does. Is it removing or cut the $ORACLE_SID from $ORACLE_HOME
[...]
Something like:
Check your shell man pages for more information. For example, if you use bash:
man bash |less -p'Parameter Expansion'