[lug] perl/awk question

arnie asherman1 at uswest.net
Thu May 18 18:51:04 MDT 2000


I have a perl script where I need to extract a particular field from the output
of ps. At the command line, if I issue the command:

 ps -ef | grep arnie | grep -v grep | awk '{print $6}'

I get the expected results, in this case all of the contents of the sixth
fields from ps. However, if I try to do this in perl like this:

@grep_array = `ps -ef | grep arnie | grep -v grep | awk '{print $6}'`;
print @grep_array;

then the output is all of the fields returned from ps, as if the awk is never
executed. I have tried escaping the ticks and curly braces, but it didn't
work. How can I correct this so I get only the specified field(s) into my
array? 

thanks,
--
arnie sherman
frenomulax at bigfoot.com

"I'm only Bob Dylan when I have to be."
		- Bob Dylan





More information about the LUG mailing list