awk - or how to select a column in perl

P

pc

hi all,

In shell I can select the second column of ps with awk: ps -ef | |
grep [some process I am looking for] | awk '{print $2}'

when running a perl script and redirecting the output of ps to a file,
eg
open(F, "ps -ef | grep [some process I am looking for] | awk '{print
$2}' | "); the ' inverted comma upsets the redirection.

Help! How can I select the second (PID) column of ps in perl?

TIA

eddiec :)
 
E

Eric J. Roode

hi all,

In shell I can select the second column of ps with awk: ps -ef | |
grep [some process I am looking for] | awk '{print $2}'

The perl equivalent to the above is:

...whatever... | perl -lane 'print $F[1]'

--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top