bash -x
$ bash -x
옵션은 디버깅을 위해 사용하는 옵션 전체 디버깅!!$ bash -x test_script.sh
======= test_script.sh ======
#!/bin/bash -x
#!/bin/bash
echo "Hello World!"
ls_al="ls -al"
eval $ls_al 1>/dev/null
[ -f $HOME/test_script.sh ] && echo "file exist"
2-1. ./test_script.sh "그냥 실행"
$ ./test_script.sh
Hello World!
file exist
2-2. $ bash -x test_script.sh
$ bash -x test_script.sh
+ echo 'Hello World!'
Hello World!
+ ls_al='ls -al'
+ eval ls -al
++ ls -al
+ '[' -f /Users/yangdonghyeon/test_script.sh ']'
+ echo 'file exist'
file exist
set [-/+]x
: 특정 부분 디버그==== test_script.sh ====
#!/bin/bash
FILE_NAME=`basename ${0}`
set -x # 쉘 디버깅 시작
if [ -f $HOME/test_script.sh ] && echo "file exist"; then
echo $FILE_NAME
fi
set +x # 쉘 디버그 종료
$ ./test_script.sh
+ '[' -f /Users/yangdonghyeon/test_script.sh ']'
+ echo 'file exist'
file exist
+ echo test_script.sh
test_script.sh
+ set +x