[plug] Re: Using the "cut" command on fields seperated with variable number of spaces

David Buddrige buddrige at wasp.net.au
Thu Jan 30 09:12:05 WST 2003


Thanks.  That does the trick. 8-) 

David.
James Devenish writes: 

> On Thu, Jan 30, 2003 at 08:59:27AM +0800, David Buddrige wrote:
>> 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]
> [...]
>> 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? 
> 
> A quick-and-dirty answer is `ps -aux | awk '{ print $2; }'` (makes a few
> assumptions about your system and ps output, and will return the 'PID'
> header as the first line, but hey...). 
> 
> 
 



More information about the plug mailing list