How to use multiple commands after "||" in Bash
You can group multiple commands within { }
. Saying:
some_command || { command1; command2; }
would execute command1
and command2
if some_command
exited with a non-zero return code.
{}
{ list; }
Placing a list of commands between curly braces causes the list to be executed in the current shell context. No subshell is created. The semicolon (or newline) following list is required.
In fact, you can use parentheses. They just tell bash "run the commands in a subshell". You can also use curlies:
ls || { echo 1 ; echo 2 ; }
Note that ;
or a newline before the closing curlie is not optional.