he.txtbash: he.txt: cannot overwrite existing file如 CentOS下如何避免文件覆盖? 黑松山资源网更新日期:2025/5/9" />

站长资源操作系统

CentOS下如何避免文件覆盖?

整理:jimmy2025/5/9浏览2
简介[root@stu227 he]# touch he.txt[root@stu227 he]# set -o noclobber[root@stu227 he]# echo "123" > he.txtbash: he.txt: cannot overwrite existing file如

[root@stu227 he]# touch he.txt

[root@stu227 he]# set -o noclobber

[root@stu227 he]# echo "123" > he.txt

bash: he.txt: cannot overwrite existing file

如果要取消限制,就把set -o 改为set +o

[root@stu227 he]# set +o noclobber

[root@stu227 he]# echo "123" > he.txt

[root@stu227 he]# cat he.txt

123