Hi Wh, > Ralph Corderoy wrote: > > What status close() returns depends on your awk. And closing a pipe > > should wait for the command to finish so if you've a grep that > > produces 1E6 lines and you just want to read the first then pipe it > > into `sed 1q' before reading it into awk so the grep gets a SIGPIPE > > on writing to the finished sed, curtailing its largess. > > To access head or tail of a ascii file the 'head' and 'tail' commands > are what you are looking at (prevents reading the whole file just to > get the result).
`sed 1q' makes sed quit of line 1 of the input without reading further input. Its default action of printing the line of input still happens. $ date; yes | sed 1q; date 2006-12-01 15:20:43 +0000 Fri y 2006-12-01 15:20:43 +0000 Fri $ Since yes(1) produces endless output, if what you're suggesting is true, that head(1) must be used to avoid reading all input, then the second date command would never run and the prompt would not re-appear. head(1) never used to exist. We used to use `sed 5q' instead of `head -5' back then. It carried on working on platforms that didn't have head. You'll still find some systems today, Plan 9 IIRC is one, that don't have head but have sed. sed's also more flexible of course, e.g. sed '/^$/q' `mhpath .` prints the headers and the terminating blank line of my current mail message allowing further processing, e.g. grep, to ignore the email's body. Anyway, this is getting a bit off-topic... Cheers, Ralph. _______________________________________________ Groff mailing list Groff@gnu.org http://lists.gnu.org/mailman/listinfo/groff