[Gllug] parsing command output

Tethys sta296 at astradyne.co.uk
Wed Feb 14 21:30:50 UTC 2007


Alain Williams writes:

>>    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.

Errr... no you don't.

>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.

Yep, I thought of adding that, but omitted it for clarity. That said,
if I was purely looking for clarity, then the awk version is better
anyway.

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

... which doesn't work. If nothing else, you're not specifying anything
for the backref to match.

>grep cat ways/of/skinning

Yep, there's an almost unlimited number of ways you could do this, even
without resorting to perl/python/ruby/scripting_language_of_the_week.

Tet
-------------- 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