[plug] Small problem with cut

Tony Breeds magni at plug.linux.org.au
Sun May 16 12:33:08 WST 2004


On Sun, May 16, 2004 at 08:53:54AM +0800, James Devenish wrote:
> Hi,
> 
> In message <200405160348.08187.mike at gilks1.com>
> on Sun, May 16, 2004 at 03:48:08AM +0800, J Michael Gilks wrote:
> > ps aux | grep "kdeinit: konqueror -session" | cut -f 6 -d " "
> > should give the result you are after.
> 
> I suggest that these are more robust (unless I've made typos):
> 
> ps auxw | fgrep 'kdeinit: konqueror -session' | awk '{print$2}'
> 
> (I.e. use awk instead of cut.)

If you're using awk you may as well do away with the grep something
like:
ps auwx | awk '/[k]deinit: konqueror -session/ {print $2}'

(untested)

The "[k]" is a smart way to avoid grabbing the awk command in the output
aswell.

Yours Tony

        Linux.Conf.AU       http://lca2005.linux.org.au/
        Apr 18-23 2005      The Australian Linux Technical Conference!



More information about the plug mailing list