I’d like to have a command only execute if the preceding command’s exit status was not 0.
i.e.
Command 1 ^ Command 2
where Command 2 is only executed when Command 1 fails.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For this, use the double-pipe (
||) operator.The second command is only executed when the first command returns non-zero, exactly as you specified.