[Gllug] parsing command output

Alain Williams addw at phcomp.co.uk
Wed Feb 14 21:03:05 UTC 2007


On Wed, Feb 14, 2007 at 08:16:11PM +0000, - Tethys wrote:

> As Alain did, I'd just do the whole thing in sed (albeit a bit more
> concisely than his):
> 
>    foo 2>&1 >/dev/null | sed -r '7,8!d;s/^ *([^ ]+ +){3}//;s/ .*//'

Hmmm, that is better, but you need a \1 in the first substitute.

I also did '-e 9q' ... 'cos if foo generates ooodles of output sed will
delete all lines 9..ooodles so stop it when you are done. This may (or may
not) be desirable since it will cause foo to be aborted some time after
generating line 8.

    foo 2>&1 >/dev/null | sed -r '7,8!d;s/^ *([^ ]+ +){3}/\1/;s/ .*//' -e 9q

grep cat ways/of/skinning

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list