I am a noob in shell-scripting. I want to print a message and exit my script if a command fails. I\'ve tried:
my_command && (echo \'my_command failed
Provided my_command is canonically designed, ie returns 0 when succeeds, then && is exactly the opposite of what you want. You want ||.
my_command
&&
||
Also note that ( does not seem right to me in bash, but I cannot try from where I am. Tell me.
(
my_command || { echo 'my_command failed' ; exit 1; }