Hi there,
I need help with retrieving particular value from the output of "ps -ef" command. Here is the situation:
Code:
ps -eaf | grep "ora_pmon_" | grep -v 'grep'
oracle 22020342 1 0 Mar 06 - 1:11 ora_pmon_db1
oracle 51577060 1 0 15:49:25 - 0:05 ora_pmon_db2
oracle 52035836 1 0 Feb 28 - 2:37 ora_pmon_db3
oracle 66125912 1 0 Feb 28 - 1:43 ora_pmon_db4
oracle 459068 1 0 09:52:55 - 0:00 ora_pmon_db5
oracle 3736018 1 0 Feb 28 - 2:08 ora_pmon_db6
Out of this output, I only want the substring of values in the last column (i.e., "db1, db2, db3..."). So this is what I tried:
Code:
ps -eaf | grep "ora_pmon_" | grep -v 'grep'|awk -F' ' '{print $9}' | nawk '{print substr($1,10)}'
OUTPUT:
=======
db1
db3
db4
db6
Please note that "db2 and db5" did not show-up in the output. Now if I change my command to the following [{print $8} instead of {print $9}], I get "db2 and db5" but all others go missing.
Code:
ps -eaf | grep "ora_pmon_" | grep -v 'grep'|awk -F' ' '{print $8}' | nawk '{print substr($1,10)}'
OUTPUT:
=======
db2
db5
-- end of output
I want to get all values like this:
Code:
db1
db2
db3
db4
db5
db6
Could someone please help me how this can be done?
Thank so much in advance!!