On Wed, 2008-02-13 at 14:56 -0600, Michael Potter wrote:
> Bash Bunch,
>
> I googled a bit and it see this problem asked several times, but I
> never really saw a slick solution:
>
> given this:
>
> set -o pipefail
> find / -type f -print 2>&1 |head -20
> echo ${PIPESTATUS[*]}
>
> prints this:
> 141 0
>
> find fails because it has a bunch of output, but head only will accept
> the first n lines.
>
> This is a problem for me because I have trap ERR & errexit & pipefail
> activated.
>
> The solution I will use will be to write the find output to a file,
> then run head on it.How about: find / -type f -print 2>&1 | (head -20; cat >/dev/null) or find / -type f -print 2>&1 | head -20 || true > I am hoping that someone on the group has a more graceful solution. It is a shame for this particular reason that head does not (perhaps as an option) consume it's input after displaying the 20 lines. b.
signature.asc
Description: This is a digitally signed message part
