I am calling find from a perl script like this:
my $one_file = `find $search_dir -name "\*.$refinfilebase.search" -print | head -n 1`;
If I execute it from the shell, I get no error. Also, it returns the right value to $one_file, but I get this on the prompt:
find: write error: Broken pipe
Why would that be? How can I get rid of this find: write error: Broken pipe message?
This "error" is perfectly normal and is to be expected.
head
which quits after getting one line of input.find
command tries to write its remaining lines to a pipe that has no one listening anymore (head
is dead).find
will throw an error.If you want to get rid of the error just do:
my $file = `find .... 2>/dev/null | head -n 1`;
This will keep the utterly predictable error from find from getting to your terminal (since neither the backticks nor the pipe into head
touch stderr, which is where that error is being printed).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With