Conditional Subsequent Command Calls

Occasionally there is a need in bash scripting to execute a series of commands in sequence conditionally. Command2 needs to be run after command1 if, and only if, the command1 succeeded (or failed). One means of performing this is to execute the command, assign the return value to a variable, and evaluate the return value executing the subsequent command based on the value. $ cat -n foo 1…