Avoid the "broken pipe" message

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

tac myfile | sed '/abc/q'

      

I understand why the message comes up: sed exits when it finds "abc" and tac has no other place to send its data. But I would like to tell Bash "OK, I expect this to happen."

+3


source to share


1 answer


Disabling SIGPIPE

should do this:



trap -- '' PIPE

      

+1


source







All Articles