使用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 onecat /dev/null同样对清除日志文件有效。
原文链接
相关文章推荐
- Linux—使用Shell命令清空或删除大文件内容的方法
- linux 操作系统中cat查看文件内容命令的使用
- linux下cat 命令使用详解(显示文件内容)
- 一天一个shell命令 linux文件内容操作系列-cat命令详解
- 使用touch命令改变文件修改时间--用Enki学Linux系列(11)
- 【linux】脚 使用 清空文件内容
- 使用cut选择一行中的部分内容--用Enki学Linux系列(13)
- 一天一个shell命令 linux文件内容操作系列-cat命令详解
- linux 每日学一点《使用grep恢复被删文件内容》
- 使用 /proc 文件系统来访问 Linux 内核的内容
- Linux下链接文件使用rm无法删除的解决办法
- Linux下链接文件使用RM无法删除的处理办法
- Linux,find 和perl正则替换文件内容、tar解压缩、cp复制、rm删除
- 使用 /proc 文件系统来访问 Linux 内核的内容
- linux清空文件内容命令
- 使用 /proc 文件系统来访问 Linux 内核的内容
- 使用 /proc 文件系统来访问 Linux 内核的内容
- 使用 /proc 文件系统来访问 Linux 内核的内容
- 使用 /proc 文件系统来访问 Linux 内核的内容
- linux 不删除文件,清空文件内容命令