[dywang@dywmac zzz]$ vim set1.sh [dywang@dywmac zzz]$ cat set1.sh #!/bin/bash echo $abc echo $USER [dywang@dywmac zzz]$ chmod +x set1.sh [dywang@dywmac zzz]$ ./set1.sh dywang
[dywang@dywmac zzz]$ vim set2.sh [dywang@dywmac zzz]$ cat set2.sh #!/bin/bash set -u echo $abc echo $USER [dywang@dywmac zzz]$ ./set2.sh ./set2.sh: line 3: abc: unbound variable
[dywang@dywmac zzz]$ vim set3.sh [dywang@dywmac zzz]$ cat set3.sh #!/bin/bash set -x echo $abc echo $USER [dywang@dywmac zzz]$ ./set3.sh + echo + echo dywang dywang
set -t
及 echo "set -t test"
。
[dywang@dywmac zzz]$ cat sh03.sh #!/bin/bash read -p "請輸入一串數字: " -t 5 num num=${num:-"1 2 3 4 5 6 7 8 9"} num=$(echo "$num" | sed 's/ /+/g') total=$(echo "$num" | bc) echo $num=$total set -t echo "set -t test" exit 0
set -t
後退出腳本,所以 echo "set -t test"
沒輸出。
[dywang@dywmac zzz]$ sh sh03.sh 請輸入一串數字: 1+2+3+4+5+6+7+8+9=45