{"id":141,"date":"2014-11-26T23:43:01","date_gmt":"2014-11-26T15:43:01","guid":{"rendered":"http:\/\/blog.haostudio.net\/hwp\/?p=141"},"modified":"2017-07-25T00:15:33","modified_gmt":"2017-07-24T16:15:33","slug":"%e5%9c%a8bash-%e4%b8%ad%e7%9a%84if-else-%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%a9%ba%e7%99%bd%e7%9a%84%e6%95%98%e8%bf%b0","status":"publish","type":"post","link":"https:\/\/blog.haostudio.net\/hwp\/%e5%9c%a8bash-%e4%b8%ad%e7%9a%84if-else-%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%a9%ba%e7%99%bd%e7%9a%84%e6%95%98%e8%bf%b0\/","title":{"rendered":"\u5728bash \u4e2d\u7684if-else \u4e2d\u4f7f\u7528\u7a7a\u767d\u7684\u6558\u8ff0"},"content":{"rendered":"<!--more-->\n<h1>\u5728bash \u4e2d\u7684if-else \u4e2d\u4f7f\u7528\u7a7a\u767d\u7684\u6558\u8ff0<\/h1>\n<pre><code>if lsof &quot;$filename&quot; &gt; \/dev\/null\nthen\n  1. file is open\n  :\nelse\n  echo &quot;deleting $filename&quot;\n  rm &quot;$filename&quot;\nfi\n<\/code><\/pre>\n<p>\u5728bash \u4e2d &#8220;:&#8221; \u8868\u793a\u7a7a\u767d\u7684\u6558\u8ff0.\n\u82e5\u6c92\u6709&#8221;:&#8221; \u5247\u6703\u51fa\u73fe\u8a9e\u6cd5\u932f\u8aa4.<\/p>\n<p>\u53c3\u8003\u4f86\u6e90: <a href=\"http:\/\/unix.stackexchange.com\/questions\/133972\/bash-syntax-error-when-else-follows-an-empty-then-clause\">Bash syntax error when \u201celse\u201d follows an empty \u201cthen\u201d clause<\/a><\/p>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57],"tags":[4,3],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-57","tag-bash","tag-shell"],"_links":{"self":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":4,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":400,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/141\/revisions\/400"}],"wp:attachment":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}