Inverting Bash Return Value
Tags: bash
grep returns 0 when it gets a hit, doing ! grep returns a 1 instead. The space is important and it works for any command.
Alternative
command && exit 1 This uses && to run on success but returns 1
Tags: bash
grep returns 0 when it gets a hit, doing ! grep returns a 1 instead. The space is important and it works for any command.
Alternative
command && exit 1 This uses && to run on success but returns 1