Vote count:
0
My script contains following sets in place:
set -o errexit
set -o pipefail
set -o nounset
Now I would like o grep (not sed, awk, etc) for letter A in file b, and add the result to the file c:
grep A b >> C
The problem is that grep exits with RC 1 if no A is found in b file, which in my case is fine as I don't see that as an issue. In that case I wrapped grep command in a function and run:
function func_1() {
grep A b >> C
}
if func_1; then
echo "OK"
else
echo "STILL OK"
end
Everything works great, but soon I realised it would be nice to catch RC=2 (grep failure). How can I do that?
asked 2 mins ago
Check grep return code
Aucun commentaire:
Enregistrer un commentaire