I'd like to have a very simple condition that will only execute if the command
fails.
In this example it's a conditional based on the SUCCESS of the command.
if command ; then
echo "Command succeeded"
fi
I'd like the opposite - how can I do this? Is there a elagant way besides doing a comparison on $?
I do not want to use the ||
or operator - it does semantically convey (in my opinion) the desired functionality. In the case of command || echo "command failed"
.
command -v "$1" >/dev/null 2>&1
– t7e Jun 25 '22 at 14:47