bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grouped pipeline clobbering question


From: Paul Jarc
Subject: Re: Grouped pipeline clobbering question
Date: Mon, 20 Mar 2006 12:33:34 -0500
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux)

Phillip Susi <psusi@cfl.rr.com> wrote:
> cat file | ( head --lines=1 ; sed -e xxxxx )
>
> I thought that head should consume the first line from the pipe, leaving 
> the rest queued for sed to consume, but this does not seem to be the 
> case.

head may read an arbitrary amount of data from the pipe, although it
will print only as much as you tell it to.  To get the behavior you
want, you'll have to duplicate head's behavior in sed:

cat file | sed -e '1,10{p;d;}' -e xxxxx

And in this case, cat is unnecessary too:

sed -e '1,10{p;d;}' -e xxxxx < file


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]