[Gllug] parsing command output

Tethys sta296 at astradyne.co.uk
Wed Feb 14 20:27:41 UTC 2007


Stuart Sears writes:

>command 3>&1 2>&3 > /dev/null | sed -n '7,8p'| awk '{print $4}' > outputfile
>
> [...]
>
>I sort of understand it, but I am probably going to have to go back and
>read it all again a few times.

Yes indeed. Your use of file descriptor 3 in the above command is
unnecessary. You could have just said:

	command 2>&1 >/dev/null

>2. I am no awk expert (to say the least. I am not even an awk amateur.),
>but it is outstanding at pulling out 'random' fields separated by
>whitespace.
>perhaps someone can enlighten me as to how I make it only print lines 7
>and 8?

	command 2>&1 >/dev/null | awk '{ if (NR==7||NR==8) print $4; }'

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