In my script, I am using the
ifne utility from the
moreutils package. The line can be simplified to the following:
printf "asdf\n" | ifne cat - && echo "stream not empty"
ifne only executes, if the stream is non-emty. But how can I make the second command (echo "stream not empty") also execute only if non empty? As it is now, in following case echo is executed (but I don't want it to be executed):
printf "" | ifne cat - && echo "stream not empty"
using parenthesis gives me syntax error:
printf "" | ifne (cat - && echo "stream not empty")
How can I execute the last command only if stream is non-empty?