wube has asked for the wisdom of the Perl Monks concerning the following question:
I can do this with "sed" but I prefer to stick to using Perl.#!/usr/bin/perl # # ps format $PSfmt = "\"pid,ppid,pgid,user\""; # ps command $PScmd = `ps -ef -o $PSfmt`; # # run the command, output into array @PSarray = $PScmd ; # # eliminate leading spaces, and condense spaces for (@PSarray) {s/^\s+//; s/ +/ /g; print "$_ \n"; } exit;
I hope someone can show me how to do this in Perl.for $rec (@PSarray) { $rec = `echo "$rec"|tr -s ' '|sed 's/^ //'`; print "$rec\n"; } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: manipulation of ps command output
by iguanodon (Priest) on Mar 09, 2004 at 23:20 UTC | |
|
Re: manipulation of ps command output
by borisz (Canon) on Mar 09, 2004 at 21:20 UTC | |
|
Re: manipulation of ps command output
by matija (Priest) on Mar 09, 2004 at 21:18 UTC | |
|
Re: manipulation of ps command output
by TilRMan (Friar) on Mar 10, 2004 at 04:57 UTC | |
|
Re: manipulation of ps command output
by Fletch (Bishop) on Mar 09, 2004 at 21:17 UTC | |
|
Re: manipulation of ps command output
by captain_haddock (Novice) on Mar 11, 2004 at 13:55 UTC | |
|
Re: manipulation of ps command output
by zentara (Cardinal) on Mar 10, 2004 at 16:34 UTC |