[NBLUG/talk] bash help

S. Saunders sms at sonic.net
Tue Feb 8 11:43:37 PST 2005


> > Hi,
> >
> > if my ps axw shows this process is there a way to get the time?
> >
> > im trying awk -F'[ ]' '{print $4}'
> >
> > 17797 ?        S      0:00 /usr/java/j2sdk1.4.2_01/....
> >
>
> Try:
>
> ps axw | awk ' { print $4 } '
>
> > but my problem lies on the number of spaces betwen ? and S and S to
> > time..

<nod>

By default, awk presumes "any whitespace" (e.g. space, tab) as a
field-separator; you don't need to specify one with "-F" if you
can use that default, nor "count" the spaces.

Note that in some versions of "ps," the fields can run together
(from the output running long) and screw up which field you get,
because the whitespace is gone. In such cases, you may need to
resort to some ugly hackery, e.g. "awk | awk", or "program" your
awk more extensively.


- Steve S.






More information about the talk mailing list