Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid "broken pipe" message

Tags:

bash

sed

Is there a way to avoid this message in a command like the following?

tac myfile | sed '/abc/q'

I understand why the message occurs: sed exits when it finds 'abc' and tac has no where else to send its data. But I would like a way to tell Bash "it's OK, I expect this to happen."

like image 667
Xu Wang Avatar asked Jun 27 '26 22:06

Xu Wang


1 Answers

Disabling SIGPIPE should do it:

trap -- '' PIPE
like image 70
Sato Katsura Avatar answered Jun 30 '26 19:06

Sato Katsura



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!