| Next | Welcome to my ~/bin | 137 |
#!/usr/bin/perl
#
# Possible options:
# omit header line
# omit self from listing
# no metacharacters
my $pat = shift or die "Usage: $0 pattern\n";
open PS, "ps -augxww |"
or die "Couldn't run ps: $!; aborting";
print scalar <PS>; # header
while (<PS>) {
print if /$pat/o;
}
A typical usage is psgrep netscape, which produces:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
mjd 7141 0.0 1.0 24208 1392 pts/10 S Jun02 1:43 /usr/lib/netscape/netscape-communicator-irix-session-management
mjd 24847 1.0 0.9 2680 1172 pts/14 S 15:08 0:00 /usr/bin/perl /home/mjd/bin/psgrep netscape
Notice: no option flags!
I decided to wait to put them in until I actually wanted them
Putting in a comment is a good way to sublimate the desire to put in the options
| Next | Menu | ![]() |
Copyright © 2005 M. J. Dominus |