Yes this works too. I think the trick is in deriving the last field in this case it was the $NF all along.
Thanks to all who replied and those who attempted to. Ross > -----Original Message----- > From: Sujatha Madan [mailto:Sujatha.Madan@;CMC.OPTUS.NET.AU] > Sent: Monday, 28 October 2002 14:38 > To: Multiple recipients of list ORACLE-L > Subject: RE: Unix Q: Substring-ing an output. > > > Hi Ross, > > Try something like this: > > DBNAME=`ps -ef | grep pmon | awk '{db=substr($NF, 10); print db}'` > > There are several ways of doing this - what's above is just one. > > Cheers > Sujatha > > -----Original Message----- > Sent: Monday, 28 October 2002 12:43 PM > To: Multiple recipients of list ORACLE-L > > > > Hi All, > > I want to feed my shell script with the names of currently running > databases. I thought of using ps -ef|grep [p]mon. What I got was the > following: > oracle 20113 1 0 Oct 25 ? 0:01 ora_pmon_TLDEV > oracle 898 1 0 Jul 22 ? 0:06 ora_pmon_TLQA > oracle 944 1 0 Jul 22 ? 0:07 ora_pmon_TLQAVAR > oracle 19588 1 0 Oct 25 ? 0:00 ora_pmon_DBMON > oracle 13509 1 0 12:16:13 ? 0:00 ora_pmon_RMAN > oracle 20450 1 0 Oct 25 ? 0:00 ora_pmon_PRDINF > oracle 13026 1 0 Oct 26 ? 0:00 ora_pmon_TLDVVAR > > What I wanted is get only the db name part eg. TLDEV, RMAN, > DBMON,etc. I > don't want to rely on oratab file. > I was thinking of using 'cut' to cut out the last field and > do some ${X##} > (variable pattern substitution) to get to the dbname bit. > The trouble is > the number of fields in a ps -ef output is not consistent. > As you can see > I've just restarted RMAN and now it only has 8 fields as > compared to 9 for > the others. > > Any suggestions? Or another way of doing it? > Using KSH on Solaris 8. > > Thanks. > Ross > -- > Please see the official ORACLE-L FAQ: http://www.orafaq.com > -- > Author: Ross Collado > INET: [EMAIL PROTECTED] > > Fat City Network Services -- 858-538-5051 http://www.fatcity.com > San Diego, California -- Mailing list and web hosting services > --------------------------------------------------------------------- > To REMOVE yourself from this mailing list, send an E-Mail message > to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in > the message BODY, include a line containing: UNSUB ORACLE-L > (or the name of mailing list you want to be removed from). You may > also send the HELP command for other information (like subscribing). > -- > Please see the official ORACLE-L FAQ: http://www.orafaq.com > -- > Author: Sujatha Madan > INET: [EMAIL PROTECTED] > > Fat City Network Services -- 858-538-5051 http://www.fatcity.com > San Diego, California -- Mailing list and web hosting services > --------------------------------------------------------------------- > To REMOVE yourself from this mailing list, send an E-Mail message > to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in > the message BODY, include a line containing: UNSUB ORACLE-L > (or the name of mailing list you want to be removed from). You may > also send the HELP command for other information (like subscribing). > -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Ross Collado INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).