Help required - in the context of shell scripting on a GNU/LINUX bash:
I always use
set -e. Often, I would like to
grep and do not always want the script to terminate execution if
grep has an exit status of
1 indicating pattern not found.
Somethings I have tried to solve this problem are as follows:
set +o pipefail and invoke grep with something like
grep 'p' | wc -l then I get the desired behaviour until a future maintainer enables
pipefail. Also, I like enabling
pipefail so this does not work for me.
awk and only print lines matching pattern, then
wc matched lines to test for matched pattern. I don't like this option because using
grep seems like a workaround for my true problem.
This one is my least favorite - something like:
set +e; grep 'p'; set-e
Any insight/idioms would be most appreciated - thank you.