Bash: Ignore error of particular command

  | #bash#linux

Add || true after the command to ignore the error and continue running the script.

with_error() {
  false
}

set -o pipefail
set -e

with_error() || true
echo "After with_error() || true" # Prints it in terminal 
with_error()
echo "After with_error()"         # Does not print it in terminal 

About Vladislav Bochenin

Photo of Vladislav Bochenin

Writing code more than 16 years and raising a son last 7 years.
So I more experienced in coding than raising.