Skip to content

Forbid output redirection to avoid overwrite the existing file

在输出重定向中,>表示重定向并覆盖已有文件内容,为了防止误操作,覆盖重要的内容,可以使用如下命令

set -C

这样输出重定向到一个已有文件就会提示

cannot overwrite existing file

如需强制覆盖,可以使用符号>|来实现

>|

关闭这一功能可以使用

set +C

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback me#imzye.me, replace # with @
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Try iOS App