您的位置:首页 > 运维架构 > Linux

使用cat而不是rm来清空文件内容--用Enki学Linux系列(9)

2017-01-17 11:25 381 查看
cat可以使我们保护文件所有权,用它来这样清空文件内容也是极好的:
$ cat /dev/null > file
#deletes the contents of the file
而不用:
$ sudo rm file && touch file
#removes the file and creates
#a new one
cat /dev/null同样对清除日志文件有效。

原文链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux