(1)sehll实例 # cat subshell #!/bin/bash if (set -u; : $var); then #冒号与$间有空格 echo "Variable is set." else echo "Not set" fi (2)输出结果: # ./subshell ./subshell: line 3: var: unbound variable Not set (3)原因分析: 其中set -u命令用于设置shell选项,u是nounset表示
下载我们在linux文本界面下测试下 $cat hao.c $wo mei you chi fan $cat > hao.c << EOF >where are you >EOF 再次cat hao.c 出现 where are you 可以看出被覆盖了 但是如果输入如下命令: $cat >> hao.c << EOF 输出的结果是: wo mei you chi fan where are you