Ì want to execute a Bash command, followed by two actions if and only if the test returns an error. I would prefer to solve this task as a one-liner in Bash.
Here are the two forms I have tried:
ssh firstname.lastname@example.org "ls /home/somefile" || echo "File does not exist" && exit 1 ssh email@example.com "ls /home/somefile" || echo "File does not exist"; exit 1
The meaning is as follows: I want to test the existance of a file on a remote machine (or whatever, just an example), and in the case the first command returns an error, then - and only then- the two following commands (
exit) should be executed. The examples above execute the
exit 1 statement independent of the return value of the
How to rewrite this line, so the
echo and the
exit commands are only executed if the first (
ssh) command fails?