在bash/ksh中设置`set -o noclobber`后,则shell将不允许IO重定向破坏一个已经存在的文件. 除非在重定向的符号之后添加一个!来显式的通知他.
set -o noclobber ls# filea filebls >filea# bash: filea: Cannot clobber existing file ls >|filea# 没问题,filea被覆盖了
本文介绍了在bash/ksh中使用set-onoclobber选项防止IO重定向破坏现有文件的方法,通过在重定向符号后添加!来实现显式覆盖。
在bash/ksh中设置`set -o noclobber`后,则shell将不允许IO重定向破坏一个已经存在的文件. 除非在重定向的符号之后添加一个!来显式的通知他.
set -o noclobber ls# filea filebls >filea# bash: filea: Cannot clobber existing file ls >|filea# 没问题,filea被覆盖了
1024

被折叠的 条评论
为什么被折叠?