[Top][All Lists]

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

broken pipe

From: Michael Potter
Subject: broken pipe
Date: Wed, 13 Feb 2008 14:56:19 -0600

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.

I am hoping that someone on the group has a more graceful solution.

BTW: I am not using find in my real script.  I just used that here so
anyone could reproduce the problem.

Michael Potter

reply via email to

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