Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing unwanted characters 1

Status
Not open for further replies.

mhauff65

Programmer
Apr 11, 2007
5
US
Hello

Here's the code
ps -ef |grep pmon |grep -v grep |awk '{print $9}'
which returns this:
ora_pmon_DEV_ORCL1
ora_pmon_ORCL2
ora_pmon_DEV_ORCL3
ora_pmon_ORCL4
ora_pmon_DEV_ORCL5

When I tried another iteration to awk to just get the SIDS
with this code:
ps -ef |grep pmon |grep -v grep |awk '{print $9}' |awk -F_ '{print $3}'
which returns this:
DEV
ORCL2
DEV
ORCL4
DEV

I tried using the sub function but I can not get the syntax correct. How do I get just the SIDs
i.e.
DEV_ORCL1
ORCL2
DEV_ORCL3
ORCL4
DEV_ORCL5

Any help anyone can provide is greatly appreciated
 
ps -ef | awk '$9~/^ora_pmon/{x=$9;sub(/ora_pmon_/,"",x);print x}'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank You Thank You Thank You. Nice and Clean!

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top