Is there a simple utility which I can pipe output to on Linux that will:
- Return a success code if there is no output on standard out (and / or standard error).
- Return a failure code if output is produced on standard out (and / or standard error).
To provide some context, the command I'm running is:
svn mergeinfo --show-revs eligible
http://mysvnserver.example.com/SVF/repos/common/abc/branches/abc-1.7
http://mysvnserver.example.com/SVF/repos/common/abc/trunk
If there are any unmerged entries on the branch, the command will return a list of revision numbers on standard out. Ideally, the additional command that I'm talking about would:
- Detect entries on standard out and return an error condition to Linux.
- Pass on the standard out so that it does end up appearing on the terminal. I'd rather not suppress it.
Best Answer
That's
grep
you're looking for:You can replace
grep '^'
withgrep .
orgrep '[^[:blank:]]'
to check for non-empty or non-blank lines (but that will remove the empty/blank ones from the output).(note the behaviour will vary across
grep
implementations if the input contains non-text data like NUL bytes or too long or non-terminated lines (which wouldn't happen forsvn
though)).