[plug] Using the "cut" command on fields seperated with variable number of spaces
Nima Talebi
nima at it.net.au
Thu Jan 30 21:51:34 WST 2003
If the problem you have is specific to ps, and not how to sort/grep/mangle
table-formatted output, why not use the options that come with ps ?
eg
ps -eo pid
Nima
----- Original Message -----
From: "David Buddrige" <buddrige at wasp.net.au>
To: <plug at plug.linux.org.au>
Sent: Thursday, January 30, 2003 8:59 AM
Subject: [plug] Using the "cut" command on fields seperated with variable
number of spaces
> Hi all,
>
> If I run the command:
>
> ps -aux
>
> I get the following output.
>
> USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
> root 1 0.0 0.0 1368 76 ? S 2002 0:04 init [5]
> root 2 0.0 0.0 0 0 ? SW 2002 0:00 [keventd]
> root 3 0.0 0.0 0 0 ? SW 2002 0:00
[kapm-idled]
> root 4 0.0 0.0 0 0 ? SW 2002 5:01 [kswapd]
> root 5 0.0 0.0 0 0 ? SW 2002 0:00 [kreclaimd]
> root 6 0.0 0.0 0 0 ? SW 2002 3:05 [bdflush]
> root 7 0.0 0.0 0 0 ? SW 2002 0:21 [kupdated]
> root 8 0.0 0.0 0 0 ? SW< 2002 0:00
[mdrecoveryd]
> root 73 0.0 0.0 0 0 ? SW 2002 0:00 [khubd]
> root 509 0.0 0.0 1428 332 ? S 2002 0:01 syslogd -m
0
> root 514 0.0 0.0 1864 112 ? S 2002 0:00 klogd -2
> rpcuser 543 0.0 0.0 1608 4 ? S 2002 0:00 rpc.statd
> root 617 0.0 0.0 0 0 ? SW 2002 0:05 [rpciod]
> root 618 0.0 0.0 0 0 ? SW 2002 0:00 [lockd]
> root 633 0.0 0.0 1352 4 ? S 2002 0:00
> /usr/sbin/apmd -p
> root 652 0.0 0.0 18012 280 ? S 2002 0:00 ypbind
>
>
> In the past, when I have tried to extract a single field from a list, I
> have used the cut command to specify the appropriate field, however in
this
> instance, there is no delimeter between the fields, other than a variable
> number of spaces. Does anyone know how to extract (for example) the PID
> field from this kind of output?
>
> thanks guys
>
> David.
>
More information about the plug
mailing list