linux-tutorial/codes/shell/demos/debug-demo.sh

29 lines
392 B
Bash
Raw Normal View History

2019-03-01 14:43:49 +08:00
#!/usr/bin/env bash
# 开启 debug
set -x
2019-10-10 08:56:31 +08:00
for (( i = 0; i < 3; i ++ )); do
printf ${i}
2019-03-01 14:43:49 +08:00
done
# 关闭 debug
set +x
# Output:
# + (( i = 0 ))
# + (( i < 3 ))
# + printf 0
# 0+ (( i++ ))
# + (( i < 3 ))
# + printf 1
# 1+ (( i++ ))
# + (( i < 3 ))
# + printf 2
# 2+ (( i++ ))
# + (( i < 3 ))
# + set +x
2019-10-10 08:56:31 +08:00
for i in {1..5}; do
printf ${i};
done
2019-03-01 14:43:49 +08:00
printf "\n"
# Output: 12345