Fails as in, grep doesn't find any results.
Then output an error message such as, "User is not logged on"
Quote:
why use grep if you still want to pass everything else to "some-other-commands" ?
Er... why not? Is there another command I can use?
I don't want to run things twice, because there are further error conditions in the subsequent set of commands. The idea is, I have a long sequence of commands, connected with pipes. If the execution fails at grep because user is not logged on, then output an error message. After grep, I retrieve the tty(s) of the user(from the grep'ed results), and if all his ttys are non-writeable, output another error message, and so on and so forth. There are multiple error conditions in the commands, and if it fails at any point, I would like to know where it fails, and output an appropriate error message.