Submit code:
ls || echo "Unable to execute ls (returned non zero)"
what if i need to execute more commands like:
ls || echo "this is echo 1" <some operator> echo "this is echo 2" <some operator> exit 1
in C (if I have the ls function), I could do (even if it looks crazy):
ls() || (command1() && command2());
but I doubt that parentheses can use parentheses in bash
edit: I know that I can create a bash function that will contain these commands, but what if I need to combine this with output 1 (exiting the function will end this function, not the whole script)
source
share