Next Welcome to my ~/bin 137

psgrep

        #!/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;
        }

        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



Next Menu Copyright © 2005 M. J. Dominus