CodyKochmann
4/8/2017 - 4:38 PM

how to do a try/catch block in bash

how to do a try/catch block in bash

# by: Cody Kochmann

# as a one liner
try_command || catch_command

# as a multi liner
{ 
  try_command_a && \
  try_command_b
} || { 
  catch_command_a && \
  catch_command_b
}