No such file or directory\n<\/code><\/pre>\n<\/p>\n\u573a\u666f\u6a21\u62df:<\/p>\n
\n
zzfdeMacBook-Air:temp zzf$ mkdir testaaa\nzzfdeMacBook-Air:temp zzf$ ls | grep testaaa\ntestaaa\nzzfdeMacBook-Air:temp zzf$ find . -type d -name \"testaaa\" -exec rm -r {} ;\nfind: .\/testaaa: No such file or directory\n<\/code><\/pre>\n<\/p>\n\u518d\u5ea6\u67e5\u627etestaaa\u76ee\u5f55\uff0c\u53d1\u89c9testaaa\u76ee\u5f55\u786e\u5b9e\u88ab\u5220\u6389\u4e86\u3002\u4f46\u4e3a\u4f55\u4f1a\u62a5:Nosuchfileordirectory\u5462\uff1f<\/p>\n
\n
zzfdeMacBook-Air:temp zzf$ ls testaaa\nls: testaaa: No such file or directory\n<\/code><\/pre>\n<\/p>\n\u67e5\u9605\u4e86find\u7684\u8d44\u6599\u540e\u53d1\u89c9\uff0cfind\u9ed8\u8ba4\u662f\u9012\u5f52\u67e5\u627e\uff0c\u5728\u6267\u884c\u524d\u9762\u7684\u5220\u6389\u76ee\u5f55\u7684\u7ec4\u5408\u547d\u4ee4\u65f6,\u5b83\u4f1a\u904d\u5386testaaa\u76ee\u5f55,\u5b9e\u9645\u6267\u884c\u8fc7\u7a0b\u5982\u4e0b:<\/p>\n
\u67e5\u8be2\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u76ee\u5f55\u8fdb\u884c\u6a21\u5f0f\u5339\u914d\"testaaa\",\u5339\u914d\u6210\u529f\uff1f\u6210\u529f\u3002\u6267\u884cexec\u540e\u7684\u547d\u4ee4:rm-rtestaaafind\u5c1d\u8bd5\u6b65\u5165\u5230testaaa\/\u76ee\u5f55\u4e2d\uff0c\u67e5\u627e\u76ee\u5f55\u6216\u6587\u4ef6\uff0c\u5e76\u6267\u884cexec\u65c1\u8fb9\u7684\u547d\u4ee4find\u6ca1\u6709\u627e\u5230testaaa\u76ee\u5f55\uff0c\u8fd4\u56deENOENT(Nosuchfileordirectory)\u89e3\u51b3\u65b9\u5f0f\u6709\u597d\u591a\u79cd\uff0c\u4e0b\u8fb9\u53ea\u5217\u4e3e\u5e38\u7528\u65b9\u6cd5:1.\u4f7f\u7528find\u7684-maxdepthOPTIONS:<\/p>\n
-maxdepthlevels\uff1a\u6307\u5b9atests\u548cactions\u4f5c\u7528\u7684\u6700\u5927\u76ee\u5f55\u6df1\u5ea6\uff0c\u53ea\u80fd\u4e3a\u975e\u8d1f\u6574\u6570\u3002\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u76ee\u5f55\u641c\u7d22\u6df1\u5ea6\uff0c\u4f46\u5e76\u975e\u8fd9\u4e48\u3002\u5f53\u524dpath\u76ee\u5f55\u7684\u5c42\u6b21\u4e3a1linux find -exec<\/strong>linux\u683c\u5f0f\u5316\u547d\u4ee4\uff0c\u6240\u4ee5\u82e5\u6307\u5b9a-maxdepth0\u5c06\u5f97\u4e0d\u5230\u4efb\u4f55\u7ed3\u679c\u3002<\/p>\n\n
zzfdeMacBook-Air:temp zzf$ ls -d testaaa\ntestaaa\nzzfdeMacBook-Air:temp zzf$\nzzfdeMacBook-Air:temp zzf$ find . -maxdepth 1 -type d -name \"testaaa\" -exec rm -r {} ;\nzzfdeMacBook-Air:temp zzf$ echo $?\n0\nzzfdeMacBook-Air:temp zzf$ ls -d testaaa\nls: testaaa: No such file or directory\n<\/code><\/pre>\n<\/p>\n2.\u4f7f\u7528find\u7684-pruneACTIONS:<\/p>\n
<\/p>\n
-prune:\u4e0d\u6b65\u5165\u76ee\u5f55\uff08\u544a\u8bc9findlinux find -exec<\/strong>\uff0c\u4e0d\u8981\u5728\u8981\u5220\u6389\u7684\u76ee\u5f55\u4e2d\u67e5\u627e\u5b50\u76ee\u5f55\u6216\u6587\u4ef6\uff09\uff0c\u6240\u4ee5\u53ef\u7528\u4e8e\u5ffd\u89c6\u76ee\u5f55\uff0c\u4f46\u4e0d\u4f1a\u5ffd\u89c6\u666e\u901a\u6587\u4ef6\u3002\u6ca1\u6709\u7ed9\u5b9a-depth\u65f6\uff0c\u603b\u662f\u8fd4\u56detrue\uff0c\u5018\u82e5\u7ed9\u5b9a-depth\uff0c\u5219\u76f4\u63a5\u8fd4\u56defalse\uff0c\u6240\u4ee5-delete(\u8574\u6db5\u4e86-depth)\u662f\u4e0d\u80fd\u548c-prune\u4e00\u8d77\u4f7f\u7528\u7684<\/p>\n\n
zzfdeMacBook-Air:temp zzf$ ls -d testaaa\ntestaaa\nzzfdeMacBook-Air:temp zzf$ find . -type d -name \"testaaa\" -prune -exec rm -r {} ;\nzzfdeMacBook-Air:temp zzf$ echo $?\n0\nzzfdeMacBook-Air:temp zzf$ ls -d testaaa\nls: testaaa: No such file or directory\n<\/code><\/pre>\n<\/p>\n3.\u4f7f\u7528find\u7684-deleteACTIONS:<\/p>\n
-delete\uff0c\u5b83\u8574\u6db5\"-depth\"\u9009\u9879<\/p>\n
<\/p>\n
-depth:\u641c\u7d22\u5230\u76ee\u5f55\u65f6\uff0c\u5148\u5904\u7406\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6(\u5b50\u76ee\u5f55)\u5e38\u7528linux\u7cfb\u7edf\uff0c\u518d\u5904\u7406\u76ee\u5f55\u672c\u8eab\u3002\u5bf9\u4e8e\"-delete\"\u8fd9\u4e2aaction\uff0c\u5b83\u8574\u6db5\"-depth\"\u9009\u9879<\/p>\n
\n
zzfdeMacBook-Air:temp zzf$ ls -d testaaa\ntestaaa\nzzfdeMacBook-Air:temp zzf$ find . -type d -name \"testaaa\" -delete\nzzfdeMacBook-Air:temp zzf$ echo $?\n0\nzzfdeMacBook-Air:temp zzf$ ls -d testaaa\nls: testaaa: No such file or directory\n<\/code><\/pre>\n<\/p>\n4.\u4f7f\u7528+(\u51cf\u53f7)\u4f5c\u4e3afind\u547d\u4ee4\u7684\u4e2d\u6b62\u7b26\uff0c\u800c\u4e0d\u4f7f\u7528;(\u5206\u53f7)<\/p>\n
+\u548c;\u533a\u522b:<\/p>\n
;\u662ffind\u904d\u5386\u4e00\u6b21\u6267\u884c\u4e00\u6b21exec\u65c1\u8fb9\u7684command\uff0c\u800c+\u4f1a\u5206\u62c6\u6279\u91cf\u627e\u5230\u7684\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u6279\u6b21\u8fd0\u884c\u547d\u4ee4\uff0c\u6240\u4ee5\u4e0d\u4f1a\u8fd4\u56de\u9519\u8bef\uff0c\u4f46\u662f\u5f53\u67e5\u627e\u5185\u5bb9\u8fc7\u591a\u65f6\uff0c+\u4f1a\u589e\u52a0CPU\u4f7f\u7528\u7387\u3002<\/p>\n
\n
zzfdeMacBook-Air:temp zzf$ ls -d testaaa\ntestaaa\nzzfdeMacBook-Air:temp zzf$ find . -type d -name \"testaaa\" -exec rm -r {} +\nzzfdeMacBook-Air:temp zzf$ echo $?\n0\nzzfdeMacBook-Air:temp zzf$ ls -d testaaa\nls: testaaa: No such file or directory\n<\/code><\/pre>\n<\/p>\n\u5176\u5b9e\u4e5f\u53ef\u4ee5\u4f7f\u7528|(\u7ba1\u7ebf)+xargs\u7684\u65b9\u6cd5:<\/p>\n
\n
find . -type d -name \"testaaa\" | xargs rm -r\n<\/code><\/pre>\n<\/p>\n\u5e76\u4e14\u5f53testaaa\u5e76\u4e0d\u5b58\u5728\u65f6\uff0c\u6267\u884c\u8fd9\u4e2a\u7ec4\u5408\u547d\u4ee4\uff0c\u4f1a\u8fd4\u56de\u4e00\u4e2a\u975e0\u7684\u72b6\u6001\u7801\uff0c\u5e76\u4e0d\u7b26\u5408\u6211\u7684\u573a\u666f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
-exec\u7ec4\u5408\u547d\u4ee4\uff0c\u4f46\u662f\u5374\u62a5\u4e86:levels\uff1a\u6307\u5b9atests\u548cactions\u4f5c\u7528\u7684\u6700\u5927\u76ee\u5f55\u6df1\u5ea6\uff0c\u53ea\u80fd\u4e3a\u975e\u8d1f\u6574\u6570\u3002-delete\uff0c\u5b83\u9690\u542b-depth\u9009\u9879\u641c\u7d22\u5230\u76ee\u5f55\u65f6\uff0c\u5148\u5904\u7406\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6(\u5b50\u76ee\u5f55)\uff0c\u518d\u5904\u7406\u76ee\u5f55\u672c\u8eab\u3002\u5bf9\u4e8e-delete\u8fd9\u4e2aaction\uff0c\u5b83\u9690\u542b-depth\u9009\u9879<\/p>\n","protected":false},"author":1,"featured_media":289774,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-289773","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/289773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=289773"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/289773\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/289774"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=289773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=289773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=289773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}