Is there a way to catch the failure in piped commands?
Here's an example of what I am trying to achieve:
#!/bin/bash
set -e # abort if error
...
command1 2>&1 | command2
...
And I notice that it command1
crashes sometimes , but command2 doesn't work and the shell script continues happily ... if I didn't have to use the pipe here set -e
would be enough, but now it doesn't work with the pipe there ...
Any thoughts? Thanks to
+3
source to share