シェルスクリプトのbashの箇所にオプションを指定してデバッグなどをし易くする方法

#!/bin/bash -xe
# -x シェルスクリプト内で実際に実行されたコマンドを表示
# -e 実行したコマンドが0でないステータスで終了した場合、即座に終了

ls .

set +x # コマンドを表示しない
echo 'This command wont display.'
set -x # コマンドを表示する

T=hello

for I in `seq 1 5`; do
  if [[ $I == 4 ]]; then
    echo 'After this, finishing this.' && false
  fi
  echo "${I} times."
done

echo "Somethings is crazy!!??"

exit 0

output

$ ./test.sh 
+ ls .
test.sh
+ set +x
This command wont display.
+ T=hello
++ seq 1 5
+ for I in '`seq 1 5`'
+ [[ 1 == 4 ]]
+ echo '1 times.'
1 times.
+ for I in '`seq 1 5`'
+ [[ 2 == 4 ]]
+ echo '2 times.'
2 times.
+ for I in '`seq 1 5`'
+ [[ 3 == 4 ]]
+ echo '3 times.'
3 times.
+ for I in '`seq 1 5`'
+ [[ 4 == 4 ]]
+ echo 'After this, finishing this.'
After this, finishing this.
+ false

シェルスクリプトの1行目に書くおまじないで使える便利オプション集 - Qiita