Operating System - HP-UX
1830503 Members
2647 Online
110006 Solutions
New Discussion

Looking for statement which captures the last column

 
Archana1
Frequent Advisor

Looking for statement which captures the last column

With --> ps -ef |grep XXXXX | awk '{print $10}' Command Iam not able to capture last column of the below output due to time stamp of the process.
Iam looking for statement which captures the last column in below output. Please help


weblogic 16400 1 0 Feb 14 ? 0:00 /bin/sh ./startwlaffi01-affinium.sh
weblogic 2330 2329 0 Mar 19 ? 0:00 /bin/sh /var/domain/wlhoards01/HOARDS/bin/startWebLogic.sh
weblogic 13254 1 0 May 12 ? 0:00 /bin/sh ./startwlart01-artemis.sh
weblogic 7131 1 0 Feb 21 ? 0:00 /bin/sh ./startwlinte01-Internet.sh
weblogic 3007 3006 0 Mar 19 ? 0:00 /bin/sh /var/domain/wlhelpfiles04/HELPFILES/bin/startWebLogic.sh
weblogic 1953 1952 0 01:17:22 ? 0:00 /bin/sh /var/domain/wlukwww01/wlukwww01/bin/startWebLogic.sh
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: Looking for statement which captures the last column

>looking for statement which captures the last column in below output.

awk '{print $NF}'
And you can use $(NF-1) too.
Prasanth V Aravind
Trusted Contributor

Re: Looking for statement which captures the last column

you can use perl too .

[root@vm1 ~]# ps -ef | grep rpc
rpc 2330 1 0 11:31 ? 00:00:00 portmap
root 2350 1 0 11:31 ? 00:00:00 rpc.statd
root 2379 1 0 11:31 ? 00:00:00 rpc.idmapd
root 3681 3628 0 11:33 pts/1 00:00:00 grep rpc
[root@vm1 ~]# ps -ef | grep rpc | perl -lane 'print $F[-1]'
portmap
rpc.statd
rpc.idmapd
rpc
[root@vm1 ~]#

Gudluck
Prasanth
Raj D.
Honored Contributor

Re: Looking for statement which captures the last column

Hi ,
Try following:

# ps -ef | awk /XXX/ '{print $NF}'


Enjoy,Have fun!.
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Looking for statement which captures the last column

correction:# ps -ef | awk '/XXXX/ {print $NF}'
" If u think u can , If u think u cannot , - You are always Right . "
Dennis Handly
Acclaimed Contributor

Re: Looking for statement which captures the last column

If you are happy with the answers you were given, please read the following about how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33