1

How to not output anything when the first command of a pipe does not output

view story
linux-howto

http://stackoverflow.com – I have 2 commands which I want to pipe like so: command1 | command2. When command1 does not output anything at all command2 still outputs. How do I stop command1 | command2 from outputting when command1 does not output anything? Concrete example: function find_string_in_file { find . -iname "*$1*" | xargs ack-grep "$2" } alias findag='find_string_in_file' If filename.py does not exist in the current directory or its subfolders then findag filename.py "some word" still returns the same output as ack-grep "some word". (HowTos)