{"id":758,"date":"2020-02-18T11:59:12","date_gmt":"2020-02-18T03:59:12","guid":{"rendered":"http:\/\/prayerlaputa.com\/?p=758"},"modified":"2020-02-18T14:08:34","modified_gmt":"2020-02-18T06:08:34","slug":"linux%e6%89%b9%e9%87%8f%e5%88%a0%e9%99%a4%e5%a4%9a%e4%b8%aa%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"http:\/\/prayerlaputa.com\/?p=758","title":{"rendered":"linux\u6279\u91cf\u5220\u9664\u591a\u4e2a\u6587\u4ef6\uff0c\u6b63\u5219\u5339\u914d\u5220\u9664\u6587\u4ef6"},"content":{"rendered":"<h1 id=\"%E4%B8%80%E8%88%AC%E7%9A%84%E5%88%A0%E9%99%A4%E6%96%87%E4%BB%B6%E7%9A%84%E6%93%8D%E4%BD%9C\" class=\"mume-header\">\u4e00\u822c\u7684\u5220\u9664\u6587\u4ef6\u7684\u64cd\u4f5c<\/h1>\n<ul>\n<li>\u5220\u9664\u51e0\u4e2a\u6587\u4ef6\u00a0<code>rm \u6587\u4ef61 \u6587\u4ef62<\/code><\/li>\n<li>\u5220\u9664\u67d0\u4e9b\u56fa\u5b9a\u5b57\u6bcd\u5f00\u5934\u7684\u6587\u4ef6 rm xxx*<\/li>\n<li>\u5220\u9664\u6587\u4ef6\u5939\u4e0b\u9762\u6240\u6709\u6587\u4ef6 rm * -rf<\/li>\n<li>\u5220\u9664\u4e00\u7c7b\u6587\u4ef6 rm *.txt<\/li>\n<\/ul>\n<h1 id=\"%E5%85%88%E7%94%A8%E6%89%BE%E5%88%B0%E6%83%B3%E5%88%A0%E9%99%A4%E7%9A%84%E6%96%87%E4%BB%B6%E5%86%8D%E6%89%A7%E8%A1%8C%E5%88%A0%E9%99%A4%E6%93%8D%E4%BD%9C\" class=\"mume-header\">\u5148\u7528\u627e\u5230\u60f3\u5220\u9664\u7684\u6587\u4ef6\uff0c\u518d\u6267\u884c\u5220\u9664\u64cd\u4f5c<\/h1>\n<h2 id=\"find%E5%91%BD%E4%BB%A4%E6%89%BE%E5%88%B0%E6%8C%87%E5%AE%9A%E6%96%87%E4%BB%B6\" class=\"mume-header\">find\u547d\u4ee4\u627e\u5230\u6307\u5b9a\u6587\u4ef6<\/h2>\n<p>\u9996\u5148\u67e5\u627e\u8981\u5220\u9664\u7684\u67d0\u7c7b\u6279\u91cf\u7684\u6587\u4ef6\uff1a<!--more--><br \/>\n<code>find . -maxdepth 1 -regex \".*ws.*\"<\/code><br \/>\nmaxdepth\u53c2\u6570\u4e3a1\u8868\u793a\u53ea\u5728\u5f53\u524d\u76ee\u5f55\u67e5\u627e\uff0c\u4e0d\u9012\u5f52\u67e5\u627e\u5b50\u76ee\u5f55<br \/>\nregex\u53c2\u6570\u662f\u6b63\u5219\u8868\u8fbe\u5f0f<br \/>\n\u4e0a\u9762\u7684\u547d\u4ee4\u8868\u793a\u67e5\u627e\u6240\u6709\u6587\u4ef6\u540d\u4e2d\u542b\u6709\u201cws\u201d\u7684\u6587\u4ef6\u3002<br \/>\nfind . -regex &#8220;.*.<span class=\"katex\"><span class=\"katex-mathml\">txt\\|sh<\/span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"mord mathdefault\">t<\/span><span class=\"mord mathdefault\">x<\/span><span class=\"mord mathdefault\">t<\/span><span class=\"mord\">\u2225<\/span><span class=\"mord mathdefault\">s<\/span><span class=\"mord mathdefault\">h<\/span><\/span><\/span><\/span>&#8221;<br \/>\n\u52a0\u53c2\u6570\u201c-regextype type\u201d\u53ef\u4ee5\u6307\u5b9a\u201ctype\u201d\u7c7b\u578b\u7684\u6b63\u5219\u8bed\u6cd5\uff0cfind\u652f\u6301\u7684\u6b63\u5219\u8bed\u6cd5\u6709\uff1avalid types are\u00a0<code>findutils-default',<\/code>awk<code>,<\/code>egrep<code>,<\/code>ed<code>,<\/code>emacs<code>,<\/code>gnu-awk<code>,<\/code>grep<code>,<\/code>posix-awk<code>,<\/code>posix-basic<code>,<\/code>posix-egrep<code>,<\/code>posix-extended<code>,<\/code>posix-minimal-basic<code>,<\/code>sed` .<\/p>\n<p>\u663e\u793a20\u5206\u949f\u524d\u7684\u6587\u4ef6<br \/>\n<code>find \/home\/prestat\/bills\/test -type f -mmin +20 -exec ls -l {} \\;<\/code><\/p>\n<p><code>find \/home\/prestat\/bills\/test -type f -mmin +20 -exec ls -l {} +<\/code><\/p>\n<p>\u5220\u966420\u5206\u949f\u524d\u7684\u6587\u4ef6<br \/>\n<code>find \/home\/prestat\/bills\/test -type f -mmin +20 -exec rm {} \\;<\/code><\/p>\n<p>\u663e\u793a20\u5929\u524d\u7684\u76ee\u5f55<br \/>\n<code>find \/home\/prestat\/bills\/test -type d -mtime +20 -exec ls -l {} \\;<\/code><\/p>\n<p>\u5220\u966420\u5929\u524d\u7684\u76ee\u5f55<br \/>\n<code>find \/home\/prestat\/bills\/test -type d -mtime +20 -exec rm {} \\;<\/code><\/p>\n<p>\u572820-50\u5929\u5185\u4fee\u6539\u8fc7\u7684\u6587\u4ef6<br \/>\n<code>find .\/ -mtime +20 -a -mtime -50 -type f<\/code><\/p>\n<p>\u6392\u9664\u67d0\u4e9b\u76ee\u5f55\uff1a<br \/>\n<code>find ${JENKINS_HOME}\/jobs -maxdepth 1 -name \"*\" -mtime +60 ! -path \/var\/lib\/jenkins\/jobs | xargs ls -ld;<\/code><\/p>\n<p>\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\uff1a<br \/>\n<code>find ${JENKINS_HOME}\/jobs -maxdepth 1 ! -name \"*.xml\" -mtime +60 ! -path \/var\/lib\/jenkins\/jobs | xargs ls -ld;<\/code><\/p>\n<h2 id=\"xargs-rm%E6%89%A7%E8%A1%8C%E5%88%A0%E9%99%A4%E6%93%8D%E4%BD%9C\" class=\"mume-header\">xargs rm\u6267\u884c\u5220\u9664\u64cd\u4f5c<\/h2>\n<p>\u6279\u91cf\u5220\u9664\u4e0a\u9762\u67e5\u627e\u5230\u7684\u6587\u4ef6\uff1a<br \/>\n<code>find . -maxdepth 1 -regex \".*ws.*\" | xargs rm -rf<\/code><br \/>\nxargs\u662f\u628a\u524d\u9762\u7684\u8f93\u51fa\u4f5c\u4e3a\u540e\u9762\u7684\u53c2\u6570\uff0c\u5982\u679c\u591a\u884c\u8f93\u51fa\uff0c\u5c31\u591a\u6b21\u6267\u884c\u540e\u9762\u7684\u547d\u4ee4<\/p>\n<p>\u6709\u7684linux\u7cfb\u7edf\u652f\u6301\u7684regex\u6b63\u5219\u8868\u8fbe\u5f0f\u4e0d\u4e00\u6837\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u66ff\u6362<br \/>\n<code>find . -maxdepth 1 -name \"*.c\" | xargs rm -rf<\/code><\/p>\n<p>\u8fd8\u6709\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u4e5f\u53ef\u4ee5\uff1a<br \/>\n<code>find . -maxdepth 1 -regex \".*ws.*\" -exec rm -rf {} \\;<\/code><\/p>\n<h1 id=\"%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\" class=\"mume-header\">\u53c2\u8003\u8d44\u6599<\/h1>\n<ul>\n<li><a href=\"https:\/\/blog.csdn.net\/mch2869253130\/article\/details\/89479695\">linux \u5220\u9664\u6587\u4ef6\uff08\u6279\u91cf\u5220\u9664\u6587\u4ef6\uff09<\/a><\/li>\n<li><a href=\"https:\/\/www.cnblogs.com\/shengulong\/p\/6742027.html\">\u6279\u91cf\u5220\u9664linux\u7684\u6587\u4ef6\uff1bfind\u65b9\u6cd5\u6279\u91cf\u5220\u9664\u6587\u4ef6\uff1bfind\u67e5\u627e\u67d0\u65f6\u95f4\u6bb5\u5185\u7684\u6240\u6709\u6587\u4ef6<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u822c\u7684\u5220\u9664\u6587\u4ef6\u7684\u64cd\u4f5c \u5220\u9664\u51e0\u4e2a\u6587\u4ef6\u00a0rm \u6587\u4ef61 \u6587\u4ef62 \u5220\u9664\u67d0\u4e9b\u56fa\u5b9a\u5b57\u6bcd\u5f00\u5934\u7684\u6587\u4ef6 rm xxx* \u5220\u9664\u6587\u4ef6 <a href='http:\/\/prayerlaputa.com\/?p=758' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[7],"tags":[34],"_links":{"self":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/758"}],"collection":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=758"}],"version-history":[{"count":3,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/758\/revisions"}],"predecessor-version":[{"id":761,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/758\/revisions\/761"}],"wp:attachment":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=758"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}