{"id":304,"date":"2023-02-24T22:09:07","date_gmt":"2023-02-24T14:09:07","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=304"},"modified":"2023-04-30T15:06:22","modified_gmt":"2023-04-30T07:06:22","slug":"linux-empty-file-content","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/24\/linux-empty-file-content\/","title":{"rendered":"Linux\u6e05\u7a7a\u6587\u4ef6\u5185\u5bb9"},"content":{"rendered":"<h3>\u4f7f\u7528\u91cd\u5b9a\u5411\u7684\u65b9\u6cd5<\/h3>\n<pre><code class=\"language-shell\"># du -h test.txt \n4.0K    test.txt\n# &gt; test.txt \n# du -h test.txt \n0    test.txt<\/code><\/pre>\n<p><!-- more --><\/p>\n<h3>\u4f7f\u7528true\u547d\u4ee4\u91cd\u5b9a\u5411\u6e05\u7a7a\u6587\u4ef6<\/h3>\n<pre><code class=\"language-shell\"># du -h test.txt \n4.0K    test.txt\n# true &gt; test.txt \n# du -h test.txt \n0    test.txt<\/code><\/pre>\n<h3>\u4f7f\u7528cat\/cp\/dd\u547d\u4ee4\u53ca\/dev\/null\u8bbe\u5907\u6765\u6e05\u7a7a\u6587\u4ef6<\/h3>\n<pre><code class=\"language-shell\"># du -h test.txt \n4.0K    test.txt\n# cat \/dev\/null &gt;  test.txt \n# du -h test.txt \n0    test.txt\n###################################################\n# echo &quot;Hello World&quot; &gt; test.txt \n# du -h test.txt \n4.0K    test.txt\n# cp \/dev\/null test.txt \ncp\uff1a\u662f\u5426\u8986\u76d6&quot;test.txt&quot;\uff1f y\n# du -h test.txt \n0    test.txt\n##################################################\n# echo &quot;Hello World&quot; &gt; test.txt \n# du -h test.txt \n4.0K    test.txt\n# dd if=\/dev\/null of=test.txt \n\u8bb0\u5f55\u4e860+0 \u7684\u8bfb\u5165\n\u8bb0\u5f55\u4e860+0 \u7684\u5199\u51fa\n0\u5b57\u8282(0 B)\u5df2\u590d\u5236\uff0c0.000266781 \u79d2\uff0c0.0 kB\/\u79d2\n# du -h test.txt \n0    test.txt<\/code><\/pre>\n<h3>\u4f7f\u7528echo\u547d\u4ee4\u6e05\u7a7a\u6587\u4ef6<\/h3>\n<pre><code class=\"language-shell\"># echo &quot;Hello World&quot; &gt; test.txt \n# du -h test.txt \n4.0K    test.txt\n# echo -n &quot;&quot; &gt; test.txt  #\u8981\u52a0\u4e0a&quot;-n&quot;\u53c2\u6570\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f1a&quot;\\n&quot;\uff0c\u4e5f\u5c31\u662f\u56de\u8f66\u7b26\n# du -h test.txt  \n0    test.txt<\/code><\/pre>\n<h3>\u4f7f\u7528truncate\u547d\u4ee4\u6e05\u7a7a\u6587\u4ef6<\/h3>\n<pre><code class=\"language-shell\"># du -h test.txt \n4.0K    test.txt\n# truncate -s 0 test.txt  #-s\u53c2\u6570\u7528\u6765\u8bbe\u5b9a\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u6e05\u7a7a\u6587\u4ef6\uff0c\u5c31\u8bbe\u5b9a\u4e3a0\n# du -h test.txt \n0    test.txt<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u91cd\u5b9a\u5411\u7684\u65b9\u6cd5 # du -h test.txt 4.0K test.txt # &gt; test.txt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-304","post","type-post","status-publish","format-standard","hentry","category-devops-base"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=304"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/304\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}