Let's say I have a bash command mycommand
. Sometimes it writes something to output but always return exit code 0. I need use pipe to fix the exit code to be 0 for empty output and something else for non-empty output.
mycommand | ???
I'm not interested in ifs nor custom commands. I want just a simple command like grep with some parameters to check if its input is empty and return the exit code.
Preferably it should print the input if it is not empty but it's not mandatory.