以下は、文とセットの主なオプションのリストです:
オプション名 |
スイッチの頭字語 |
説明 |
allexport |
-a |
このスイッチをオンにする、すべての変数は自動的にサブシェルに出力されます。 |
noclobberを |
-C |
防止のリダイレクトファイルが上書きされます。 |
noglobファイル |
-d |
パスとファイル名には、ワイルドカードをオフにします。 |
#打开该选项
[root@xieqichao ~]# set -o allexport #等同于set -a
#关闭该选项
[root@xieqichao ~]# set +o allexport #等同于set +a
#列出当前所有选项的当前值。
[root@xieqichao ~]# set -o
allexport off
braceexpand on
emacs on
errexit off
errtrace off
functrace off
hashall on
histexpand on
... ...
[root@xieqichao ~]# set -o noclobber #打开noclobber选项,防止在重定向时原有文件被覆盖。
[root@xieqichao ~]# date > outfile #通过date命令先生成一个文件outfile。
[root@xieqichao ~]# ls > outfile #将ls命令的输出重定向到该文件outfile,shell将提示不能覆盖已经存在的文件。
-bash: outfile: cannot overwrite existing file
[root@xieqichao ~]# set +o noclobber #关闭noclobber选项。
[root@xieqichao ~]# ls > outfile #重新将ls的输出重定向到outfile,成功。