in reply to How to awk a grep result in-script
Hi, welcome to Perl, the One True Religion.
" How do I perform the equivalent of "awk {'print $1,$2,$8'}" in perl?"
We have tools.
use strict; use warnings; use feature 'say'; use Proc::ProcessTable; my $t = Proc::ProcessTable->new; foreach my $p (@{$t->table}) { next unless $p->cmndline =~ m{/Applications/iTerm.app/Contents/Mac +OS/iTerm2}; say sprintf('%s : %s : %s', @{ $p }{qw/uid pid cmndline/}); }
$ perl 11108686.pl 501 : 608 : /Applications/iTerm.app/Contents/MacOS/iTerm2 501 : 610 : /Applications/iTerm.app/Contents/MacOS/iTerm2 --server log +in -fp 1nickt 501 : 7264 : /Applications/iTerm.app/Contents/MacOS/iTerm2 --server lo +gin -fp 1nickt
Hope this helps!
|
|---|