bash -n script.sh (syntax check)shellcheck script.sh (lint, if installed)set -x / bash -x script.sh (trace)set -euo pipefail (fail fast + catch unset vars)bash -x script.sh arg1 arg2
More controlled:
set -x
do_work
set +x
"$var" and "$@"read -r and IFS=set -o pipefailtime ./script.sh
Measure sections:
start="$(date +%s)"
do_work
echo "elapsed=$(( $(date +%s) - start ))s"
awk once instead of multiple grep | cut | sed when appropriatecat file | ... when the tool accepts a filename directly