{"id":272142,"date":"2023-05-15T04:06:54","date_gmt":"2023-05-14T20:06:54","guid":{"rendered":"https:\/\/lrxjmw.cn\/lzczwjdml.html"},"modified":"2023-05-15T04:06:54","modified_gmt":"2023-05-14T20:06:54","slug":"lzczwjdml","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lzczwjdml.html","title":{"rendered":"Linux\u4e2d\u67e5\u627e\u6587\u4ef6\u7684\u547d\u4ee4"},"content":{"rendered":"

find\u547d\u4ee4 linux_linux \u7cfb\u7edf find\u547d\u4ee4\u6e90\u4ee3\u7801_linux\u547d\u4ee4find<\/p>\n

Linux<\/a>\u4e2d\u67e5\u627e\u6587\u4ef6\u7684\u547d\u4ee4<\/a>\u6709\u597d\u591a\uff0c\u53ef\u80fd\u4f60\u4eec\u666e\u904d\u7528\u5230\u6bd4\u8f83\u591a\u7684\u662ffind\uff0c\u4f46locate\u3001whereis\u3001which\u4e5f\u662f\u6bd4\u8f83\u597d\u7528\u7684\u67e5\u627e\u547d\u4ee4\u3002<\/p>\n

\u5b83\u4eec\u7684\u4e3b\u8981\u533a\u522b\u662f\uff1a<\/p>\n

find\uff1a\u662f\u4e2a\u5f88\u5f3a\u608d\u7684\u67e5\u627e\u547d\u4ee4\uff0c\u80fd\u505a\u5230\u5b9e\u65f6\u67e5\u627e\uff0c\u7cbe\u786e\u67e5\u627e\uff0c\u4f46\u67e5\u627e\u5185\u5bb9\u8f83\u591a\u65f6\u901f\u7387\u6162\uff0c\u6548\u7387\u4f4e<\/p>\n

locate\uff1a\u67e5\u627e\u901f\u7387\u5feblinux \u7248\u672c\uff0c\u4f46\u4e0d\u662f\u5b9e\u65f6\u67e5\u627e\uff0c\u67e5\u627e\u7684\u7ed3\u679c\u4e0d\u7cbe\u786e<\/p>\n

whereis\uff1a\u7528\u4e8e\u67e5\u627e\u4e8c\u8865\u7801\u6587\u4ef6\u3001\u6e90\u4ee3\u7801\u6587\u4ef6\u548c\u5e2e\u52a9\u6307\u5357\uff1b<\/p>\n

which\uff1a\u4f1a\u5728\u73af\u5883\u53d8\u91cf$PATH\u8bbe\u7f6e\u7684\u76ee\u5f55\u91cc\u67e5\u627e\u7b26\u5408\u6761\u4ef6\u7684\u6587\u4ef6<\/p>\n

1<\/p>\n

find\u67e5\u627e\u6587\u4ef6<\/p>\n

find\u62ff\u6765\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u67e5\u627e\u6587\u4ef6\u3002<\/p>\n

\u4efb\u4f55\u5750\u843d\u53c2\u6570\u4e4b\u524d\u7684\u5b57\u7b26\u4e32\u90fd\u5c06\u88ab\u89c6\u4e3a\u6b32\u67e5\u627e\u7684\u76ee\u5f55\u540d\u3002<\/p>\n

linux \u7cfb\u7edf find\u547d\u4ee4\u6e90\u4ee3\u7801_find\u547d\u4ee4 linux_linux\u547d\u4ee4find<\/p>\n

\u5047\u5982\u4f7f\u7528\u8be5\u547d\u4ee4\u65f6\uff0c\u4e0d\u8bbe\u7f6e\u4efb\u4f55\u53c2\u6570\uff0c\u5219find\u547d\u4ee4\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u67e5\u627e\u5b50\u76ee\u5f55\u4e0e\u6587\u4ef6\u3002\u800c\u4e14\u5c06\u67e5\u627e\u5230\u7684\u5b50\u76ee\u5f55\u548c\u6587\u4ef6\u5168\u90e8\u8fdb\u884c\u663e\u793a\u3002<\/p>\n

find<\/p>\n

path\uff1a\u6240\u8981\u641c\u7d22\u7684\u76ee\u5f55\u53ca\u5176\u6240\u6709\u5b50\u76ee\u5f55\u3002\u9ed8\u8ba4\u4e3a\u5f53\u524d\u76ee\u5f55\u3002<\/p>\n

expression\uff1a\u6240\u8981\u641c\u7d22\u7684\u6587\u4ef6\u7684\u7279\u70b9\u3002<\/p>\n

-cminn:\u5728\u8fc7\u53bbn\u5206\u949f\u5185\u88ab\u66f4\u6539\u8fc7<\/p>\n

-ctimen:\u5728\u8fc7\u53bbn\u5929\u5185\u88ab\u66f4\u6539\u8fc7\u7684\u6587\u4ef6<\/p>\n

-mtimen\uff1a\u5728\u8fc7\u53bbn\u5929\u5185\u88ab\u66f4\u6539\u8fc7\u7684\u6587\u4ef6<\/p>\n

-mminn\uff1a\u5728\u8fc7\u53bbn\u5206\u949f\u5185\u88ab\u66f4\u6539\u8fc7<\/p>\n

-empty:\u7a7a\u7684\u6587\u4ef6\uff0c\u627e\u5bfb\u6587\u4ef6\u5927\u5c0f\u4e3a0Byte\u7684\u6587\u4ef6\uff0c\u6216\u76ee\u5f55\u4e0b\u6ca1\u6709\u4efb\u4f55\u5b50\u76ee\u5f55\u6216\u6587\u4ef6\u7684\u7a7a\u76ee\u5f55\uff1b<\/p>\n

-ipathp,-pathp:\u5339\u914d\u6587\u4ef6\u8def\u5f84\u9a6c\u54e5linux\uff0cipath\u4f1a\u5ffd\u89c6\u8def\u5f84\u5927\u5c0f\u5199<\/p>\n

-namename\uff0c-inamename:\u5339\u914d\u6587\u4ef6\u540d\u79f0\u3002iname\u4f1a\u5ffd\u89c6\u540d\u79f0\u5927\u5c0f\u5199<\/p>\n

-sizen:\u5339\u914d\u6587\u4ef6\u5927\u5c0f\uff0c\u5355\u4f4d\u6709\uff1ac--\u5b57\u8282\uff0ck--\u5343\u5b57\u8282\uff0cM--\u5146\u5b57\u8282\uff0cG--GB<\/p>\n

-typec:\u5339\u914d\u6587\u4ef6\u7c7b\u578b\uff0cc\u662f\u6307\u5b9a\u7684\u7c7b\u578b\u3002(\u6587\u4ef6\u7c7b\u578b\u53c2\u6570\u6709\uff1af--\u666e\u901a\u6587\u4ef6\uff0cd--\u76ee\u5f55\uff0cl--\u7b26\u53f7\u94fe\u63a5)<\/p>\n

-exec\uff1a\u5047\u5b9afind\u6307\u4ee4\u7684\u56de\u4f20\u503c\u4e3aTrue\uff0c\u5c31\u6267\u884c\u8be5\u6307\u4ee4\uff1b<\/p>\n

-ok\uff1a\u6b64\u53c2\u6570\u7684\u7597\u6548\u548c\u6307\u5b9a\u201c-exec\u201d\u7c7b\u4f3c\uff0c\u4f46\u5728\u6267\u884c\u6307\u4ee4\u4e4b\u524d\u4f1a\u5148\u5bfb\u95ee\u7528\u6237\uff0c\u82e5\u56de\u7b54\u201cy\u201d\u6216\u201cY\u201d\uff0c\u5219\u820d\u5f03\u6267\u884c\u547d\u4ee4\uff1b<\/p>\n

-regex\uff1a\u6307\u5b9a\u5b57\u7b26\u4e32\u4f5c\u4e3a\u627e\u5bfb\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8303\u672c\u5f0f\u6837<\/p>\n

\u5c06\u5f53\u524d\u76ee\u5f55\u53ca\u5176\u5b50\u76ee\u5f55\u4e0b\u6240\u6709.py\u540e\u7f00\u7684\u6587\u4ef6\u5217\u4e0b\u6765\uff1a<\/p>\n

find.-name\"*.py\"<\/p>\n

find.-iname\"*.py\"<\/p>\n

\u5339\u914d\u6587\u4ef6\u8def\u5f84\u6216\u5219\u6587\u4ef6\uff1a<\/p>\n

linux\u547d\u4ee4find_find\u547d\u4ee4 linux_linux \u7cfb\u7edf find\u547d\u4ee4\u6e90\u4ee3\u7801<\/p>\n

find\/usr\/-path\"*local*\"<\/p>\n

\u57fa\u4e8e\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6587\u4ef6\u8def\u5f84\uff1a<\/p>\n

find.-regex\".*(.txt|.doc)$\"<\/p>\n

\uff08\u67e5\u627e\u5f53\u524d\u76ee\u5f55\u53ca\u5b50\u76ee\u5f55\u4e0b\u6240\u6709\u4ee5.txt\u6216.doc\u7ed3\u5c3e\u7684\u6587\u4ef6\uff09<\/p>\n

\u67e5\u627e\u8fd1\u67653\u5929\u5185\u88ab\u8bbf\u95ee\u8fc7\u7684\u6240\u6709\u6587\u4ef6\uff1a<\/p>\n

find.-typef-atime-3<\/p>\n

\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u67e5\u627e\u6587\u4ef6\u5bbd\u5ea6\u5c0f\u4e8e10kb\u7684\u6587\u4ef6<\/p>\n

find.-size+10k<\/p>\n

2<\/p>\n

locate\u67e5\u627e\u6587\u4ef6<\/p>\n

linux\u547d\u4ee4find_find\u547d\u4ee4 linux_linux \u7cfb\u7edf find\u547d\u4ee4\u6e90\u4ee3\u7801<\/p>\n

locate\u67e5\u627e\u547d\u4ee4\u6bd4\u8f83\u7b80\u5355\u4e14\u4e0d\u662f\u5b9e\u65f6\u7684linux \u7cfb\u7edf<\/a> find\u547d\u4ee4\u6e90\u4ee3\u7801<\/strong>\uff0c\u800c\u662f\u4ee5\u6570\u636e\u5e93\u7684\u66f4\u65b0\u4e3a\u51c6\u3002<\/p>\n

locate\u5b9e\u9645\u4e0a\u67e5\u7684\u662f\u4e00\u4e2a\u4fdd\u5b58\u6587\u6863\u548c\u76ee\u5f55\u540d\u79f0\u7684\u6570\u636e\u5e93\uff0c\u9ed8\u8ba4\u662f\/var\/lib\/slocate\/slocate.db<\/p>\n

Linux\u7cfb\u7edf\u624b\u52a8\u521b\u5efa\u8fd9\u4e2a\u6570\u636e\u5e93\uff0c\u4f46\u662f\u6bcf\u665a\u624b\u52a8\u66f4\u65b0\u4e00\u6b21\uff0c\u4e3a\u6b64\uff0c\u6211\u4eec\u5728\u7528locate\u67e5\u627e\u6587\u4ef6\u65f6\uff0c\u6709\u65f6\u4f1a\u627e\u5230\u65e9\u5df2\u88ab\u5220\u6389\u7684\u6570\u636e\uff0c\u6216\u5219\u521a\u624d\u6784\u5efa\u6587\u4ef6\uff0c\u5374\u96be\u4ee5\u67e5\u627e\u5230linux \u7cfb\u7edf find\u547d\u4ee4\u6e90\u4ee3\u7801<\/strong>\uff0c\u8bf1\u56e0\u5c31\u662f\u7531\u4e8e\u6570\u636e\u5e93\u6587\u4ef6\u6ca1\u6709\u88ab\u66f4\u65b0\u3002<\/p>\n

\u4e3a\u4e86\u9632\u6b62\u8fd9\u4e9b\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728\u4f7f\u7528locate\u4e4b\u524d\uff0c\u5148\u4f7f\u7528updatedb\u547d\u4ee4\uff0c\u81ea\u52a8\u66f4\u65b0\u6570\u636e\u5e93\uff08\u4e5f\u53ef\u4ee5\u4f7f\u7528locate-u\u547d\u4ee4\u6765\u66f4\u65b0\uff09<\/p>\n

\u67e5\u627e\u51fa\u4ee5passwd\u5f00\u5934\u7684\u6240\u6709\u6587\u4ef6<\/p>\n

locatepasswd<\/p>\n

\u67e5\u627e\u51fa\/data\/jjing\/\u76ee\u5f55\u4e0b\u6240\u6709\u4ee5test\u5f00\u5934\u7684\u6587\u4ef6\u6216\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709\u5185\u5bb9<\/p>\n

locate\/data\/jjing\/test<\/p>\n

3<\/p>\n

whereis\u67e5\u627e\u6587\u4ef6<\/p>\n

whereis\u547d\u4ee4\u53ea\u80fd\u7528\u4e8e\u7a0b\u5e8f\u540d\u7684\u641c\u7d22\uff0c\u5e76\u4e14\u53ea\u641c\u7d22\u4e8c\u8865\u7801\u6587\u4ef6\uff08\u53c2\u6570-b\uff09\u3001man\u8bf4\u660e\u6587\u4ef6\uff08\u53c2\u6570-m\uff09\u548c\u6e90\u4ee3\u7801\u6587\u4ef6\uff08\u53c2\u6570-s\uff09\u3002\u5047\u5982\u7701\u7565\u53c2\u6570\uff0c\u5219\u8fd4\u56de\u6240\u6709\u4fe1\u606f\u3002<\/p>\n

\u67e5\u627epasswd\u8fd9\u4e2a\u6587\u4ef6\u540d\u6709\u5173\u7684\u6240\u6709\u6570\u636e<\/p>\n

#whereispasswd<\/p>\n

passwd:\/usr\/bin\/passwd\/etc\/passwd\/usr\/share\/man\/man1\/passwd.1.gz<\/p>\n

4<\/p>\n

which\u67e5\u627e\u6587\u4ef6<\/p>\n

which\u547d\u4ee4\u7684\u4f5c\u7528\u662f\uff0c\u5728PATH\u53d8\u91cf\u6307\u5b9a\u7684\u8def\u5f84\u4e2d\uff0c\u641c\u7d22\u67d0\u4e2a\u7cfb\u7edf\u547d\u4ee4\u7684\u4f4d\u7f6e\uff0c\u4f46\u662f\u8fd4\u56de\u7b2c\u4e00\u4e2a\u641c\u7d22\u7ed3\u679c\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f7f\u7528which\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u770b\u89c1\u67d0\u4e2a\u7cfb\u7edf\u547d\u4ee4\u662f\u5426\u5b58\u5728\uff0c\u4ee5\u53ca\u6267\u884c\u7684\u7a76\u7adf\u662f\u54ea\u4e00\u4e2a\u4f4d\u7f6e\u7684\u547d\u4ee4\u3002<\/p>\n

$whichgrep<\/p>\n

\/bin\/grep<\/p>\n

Linux\u67e5\u627e\u6587\u4ef6\u7684\u547d\u4ee4\u5c31\u4ecb\u7ecd\u5982\u6b64\u591a\u4e86\uff0c\u5173\u6ce8\u300c\u7231\u8f6f\u6d4b\u300d\uff0c\u4e00\u8d77\u63d0\u9ad8\u6d4b\u8bd5\u6280\u672f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

whereis\uff1a\u7528\u4e8e\u67e5\u627e\u4e8c\u8fdb\u5236\u6587\u4ef6\u3001\u6e90\u4ee3\u7801\u6587\u4ef6\u548c\u5e2e\u52a9\u624b\u518c\uff1b\u5982\u679c\u4f7f\u7528\u8be5\u547d\u4ee4\u65f6\uff0c\u4e0d\u8bbe\u7f6e\u4efb\u4f55\u53c2\u6570\uff0c\u5219find\u547d\u4ee4\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u67e5\u627e\u5b50\u76ee\u5f55\u4e0e\u6587\u4ef6\u3002\u67e5\u627e\u6587\u4ef6\u65f6\uff0c\u6709\u65f6\u4f1a\u627e\u5230\u5df2\u7ecf\u88ab\u5220\u9664\u7684\u6570\u636e\uff0c\u6216\u8005\u521a\u521a\u5efa\u7acb\u6587\u4ef6\uff0c\u5374\u65e0\u6cd5\u67e5\u627e\u5230\uff0c\u539f\u56e0\u5c31\u662f\u56e0\u4e3a\u6570\u636e\u5e93\u6587\u4ef6\u6ca1\u6709\u88ab\u66f4\u65b0\u3002whereis\u547d\u4ee4\u53ea\u80fd\u7528\u4e8e\u7a0b\u5e8f\u540d\u7684\u641c\u7d22\uff0c\u800c\u4e14\u53ea\u641c\u7d22\u4e8c\u8fdb\u5236\u6587\u4ef6\uff08\u53c2\u6570-b\uff09\u3001man\u8bf4\u660e\u6587\u4ef6\uff08\u53c2\u6570-m\uff09\u548c\u6e90\u4ee3\u7801\u6587\u4ef6\uff08\u53c2\u6570-s\uff09\u3002<\/p>\n","protected":false},"author":1,"featured_media":272143,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-272142","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\/272142","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=272142"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/272142\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/272143"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=272142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=272142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=272142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}