[ale] Silly bash question
Don Lachlan
ale-at-ale.org at unpopularminds.org
Sun Nov 15 14:35:30 EST 2009
On Thu, Nov 12, 2009 at 3:51 PM, Ed Cashin <ecashin at noserose.net> wrote:
> for pid in `jobs -p`; do
> echo `ps aux | awk -vp=$pid '$2==p{print $11}'`: "$pid"
> done
If you aren't redirecting stdout, you don't need "echo". And you
actually don't need "awk" if you already know the pid.
for pid in `jobs -p` ; do
ps -p ${pid} --no-headers -o 'pid,args'
done
>From the 'ps' man page:
-p pidlist Select by PID.
This selects the processes whose process ID
numbers appear in pidlist.
Identical to p and --pid.
-o format user-defined format.
format is a single argument in the form of a
blank-separated or
comma-separated list, which offers a way to
specify individual output
columns. The recognized keywords are described
in the STANDARD FORMAT
SPECIFIERS section below.
--no-headers print no header line at all. --no-heading is an alias
for this option.
Generally, if you're considering 'awk' and 'ps' together, then you
want to use at least one of those three options.
-Lachlan
More information about the Ale
mailing list