首页 > 文章列表 > CentOS中如何防止文件被覆盖?

CentOS中如何防止文件被覆盖?

centos 文件覆盖
184 2024-02-06

[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