ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [Shell] Input null到文件中的两个方法

[Shell] Input null到文件中的两个方法

原创 Linux操作系统 作者:tolilong 时间:2016-03-16 21:04:07 0 删除 编辑
Input null到文件中的两个方法

[mon@oracle6 data]$ echo > mon_host_stat.log 
[mon@oracle6 data]$ ll
-rw-rw-r--. 1 mon mon     1 Mar  2 23:22 mon_host_stat.log
直接echo >到文件的时候,文件大小为1,文件中的内容部位null

如果需要将文件清空为null 可以使用如下两种方法
1.cat /dev/null > mon_host_stat.log 
[mon@oracle6 data]$ cat /dev/null > mon_host_stat.log 
[mon@oracle6 data]$ ll mon_host_stat.log 
-rw-rw-r--. 1 mon mon 0 Mar  2 23:24 mon_host_stat.log

2.echo -n "" > mon_host_stat.log
[mon@oracle6 data]$ ll mon_host_stat.log 
-rw-rw-r--. 1 mon mon 1 Mar  2 23:24 mon_host_stat.log
[mon@oracle6 data]$ echo -n "" > mon_host_stat.log 
[mon@oracle6 data]$ ll mon_host_stat.log 
-rw-rw-r--. 1 mon mon 0 Mar  2 23:25 mon_host_stat.log

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-2058461/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-13

  • 博文量
    406
  • 访问量
    1208686