linux-command/c/find.html

793 lines
177 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="description" content="find:在指定目录下查找文件 - 最专业的Linux命令大全内容包含Linux命令手册、详解、学习值得收藏的Linux命令速查手册。">
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,find,在指定目录下查找文件">
<title>find 命令Linux find 命令详解:在指定目录下查找文件 - Linux 命令搜索引擎</title>
<link rel="shortcut icon" href="../img/favicon.ico">
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1751947536256">
<script src="../js/dark-mode.min.js"></script>
<script type="module" src="../js/github-corners.js"></script>
</head>
<body>
<dark-mode permanent dark="Dark" light="Light" style="position: fixed;left: 10px;top: 8px; z-index: 999;"></dark-mode>
<github-corners target="__blank" z-index="999" position="fixed" href="https://github.com/jaywcjlove/linux-command"></github-corners>
<div class="header header_list">
<div class="header_inner">
<div class="logo">
<a href="/">
<svg width="183px" height="48px" viewBox="0 0 183 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- kenny wang <wowohoo@qq.com> https://github.com/jaywcjlove --> <title>logo</title> <desc>Linux Command Logo. https://github.com/jaywcjlove</desc><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g transform="translate(-576.000000, -261.000000)" fill="currentColor"> <g id="logo" transform="translate(576.000000, 261.000000)"> <path d="M20.4917792,0.000336524232 C20.1886146,-0.000100520225 19.8723998,0.0124863601 19.542641,0.0387964365 C11.2083649,0.710004944 13.4186692,9.51473754 13.2949769,12.4631618 C13.1427718,14.6193207 12.7056049,16.3185233 11.2226825,18.426428 C9.48047033,20.4982285 7.02763261,23.8514609 5.86566251,27.3420607 C5.3172635,28.9894735 5.05630425,30.6686289 5.29730805,32.2578406 C5.22181299,32.325447 5.14994103,32.3962788 5.08160039,32.469239 C4.57008792,33.0153217 4.19213625,33.6769851 3.77100458,34.1224689 C3.37755968,34.5149436 2.81698897,34.6642292 2.20097918,34.8852382 C1.58472464,35.1063477 0.908127379,35.4323261 0.497432332,36.2204265 C0.497432332,36.2204265 0.497432332,36.2207368 0.49712203,36.2207368 C0.496684986,36.222048 0.495373852,36.2233591 0.494936808,36.2246702 L0.494936808,36.2246702 C0.123151829,36.919077 0.233680372,37.718746 0.347224522,38.4596325 C0.460773043,39.2004972 0.575720105,39.9005856 0.423139144,40.3755699 C-0.0645762474,41.7086473 -0.126850712,42.6307542 0.216491414,43.2996202 C0.560563403,43.9698759 1.2680029,44.2657113 2.06756262,44.432706 C3.66668644,44.7666954 5.83232039,44.6837094 7.53908826,45.5883128 L7.68579097,45.3115063 L7.54060917,45.5891344 C9.36778716,46.5444437 11.2201913,46.8837519 12.698079,46.5461831 C13.7695766,46.3014513 14.6393781,45.6634363 15.0860725,44.6816946 C16.2420201,44.6760567 17.5104717,44.1864315 19.5423657,44.0745568 C20.9208039,43.9635213 22.6427241,44.564051 24.6233484,44.4540775 C24.6751207,44.6689591 24.750052,44.8756375 24.8526175,45.0720452 C24.8539287,45.0742305 24.8548028,45.0759786 24.8556769,45.0780328 C25.6234722,46.6133699 27.0500902,47.3156173 28.570428,47.1956355 C30.0927718,47.075492 31.711331,46.1778551 33.0196848,44.6208231 L32.7798304,44.4192582 L33.0215204,44.618616 C34.2685787,43.1065034 36.3384911,42.4794975 37.7110118,41.6516741 C38.3972721,41.2377581 38.9541192,40.7194802 38.9971462,39.966706 C39.0401514,39.2142991 38.5984218,38.3711223 37.5826868,37.2436088 L37.5823765,37.2432985 C37.5820662,37.2428614 37.5815024,37.2424244 37.5810654,37.2415503 C37.2473295,36.8644028 37.0881185,36.1654026 36.91702,35.4210285 C36.7460395,34.6771089 36.5551865,33.8746254 35.9444344,33.3545687 L35.9444344,33.3545687 C35.9431233,33.3532575 35.9418121,33.3523835 35.940938,33.3515094 L35.940938,33.3515094 C35.6978714,33.1397045 35.4452772,32.9959518 35.1909042,32.8993694 C36.0400422,30.3810493 35.7068789,27.8734149 34.8497254,25.6073831 C33.7977638,22.8263338 31.9611937,20.4030752 30.5585738,18.7453569 C28.9885703,16.7650385 27.4529665,14.8848863 27.4832187,12.1079627 C27.5299825,7.86977213 27.9494053,0.0101787654 20.4914689,0 L20.4917792,0.000336524232 Z M21.5014393,6.5296802 C21.9246338,6.5296802 22.2860696,6.65372652 22.6573476,6.92320377 C23.0345213,7.1969553 23.3062494,7.53965497 23.5252523,8.01821865 C23.7401952,8.48461502 23.843613,8.94086321 23.8537568,9.48229573 C23.8537568,9.49649968 23.8537568,9.50864951 23.8576902,9.52285346 C23.8616236,10.0784681 23.7664397,10.5509481 23.5555483,11.0335676 C23.4352081,11.3089536 23.2970146,11.540089 23.1316064,11.7401941 C23.0754506,11.7132285 23.0171357,11.6873118 22.9566488,11.6624396 L22.9566488,11.6624396 C22.5373789,11.4828667 22.2157491,11.3685884 21.9476879,11.2755722 C22.044856,11.158772 22.1257661,11.0202464 22.1969169,10.8470719 C22.3043949,10.5854877 22.3571155,10.3299784 22.367255,10.025813 C22.367255,10.0136631 22.3711884,10.00348 22.3711884,9.98931975 C22.3772633,9.69732161 22.3387597,9.44789596 22.2535753,9.19239103 C22.1643483,8.92472316 22.0507955,8.73208707 21.886541,8.57188842 C21.722291,8.41168541 21.5580366,8.33869024 21.361336,8.33260221 C21.3521143,8.33216517 21.3429364,8.33216517 21.3338459,8.33216517 C21.1488275,8.33260221 20.9881699,8.39616596 20.8219532,8.53532529 C20.6475593,8.6813331 20.5177834,8.86788115 20.4103054,9.12744186 C20.3028318,9.38699819 20.2501067,9.64452664 20.239976,9.95073309 C20.2377908,9.96288293 20.2377908,9.97306607 20.2377908,9.9852159 C20.2342945,10.1535261 20.2449584,10.307711 20.2709188,10.4574381 C19.8923378,10.2687966 19.535574,10.1401875 19.2007499,10.0604924 C19.181651,9.91570835 19.1706375,9.76629596 19.1670975,9.61007442 L19.1670975,9.56750629 C19.1610225,9.01391519 19.2522643,8.53941165 19.4651836,8.05679657 C19.6781029,7.57417712 19.9417194,7.2274173 20.3128051,6.94555422 C20.6838952,6.66369114 21.0488973,6.53391079 21.4808239,6.52985938 L21.5010154,6.52985938 L21.5014393,6.5296802 Z M15.7091362,6.98827969 C15.9898804,6.98871673 16.2410892,7.0827381 16.5009296,7.29023807 C16.7828014,7.51531597 16.9957164,7.80326271 17.1741616,8.20882685 C17.3526112,8.614391 17.4479175,9.01995077 17.4742757,9.49851445 L17.4742757,9.50244785 C17.4870374,9.70344023 17.485464,9.89263677 17.469643,10.0758677 C17.4141165,10.091645 17.3597045,10.1087334 17.3064069,10.1270762 C17.0036968,10.2312719 16.7369205,10.373272 16.5044085,10.5268101 C16.5271785,10.366205 16.5305437,10.2032486 16.5131057,10.0215605 C16.5109204,10.0114211 16.5109204,10.0032921 16.5109204,9.99319633 C16.4865771,9.75189098 16.435893,9.54911109 16.3507218,9.34429895 C16.2594713,9.131384 16.1580813,8.98132478 16.0242452,8.86573527 C15.9029566,8.76098882 15.7883592,8.71289208 15.6622806,8.71384046 C15.6492567,8.71384046 15.636058,8.71427751 15.6227281,8.71558864 C15.4807804,8.72773848 15.3631674,8.79669098 15.251638,8.93255936 C15.1401086,9.068419 15.0671091,9.23672919 15.0143884,9.4597792 C14.9616634,9.68284232 14.9474682,9.90184967 14.9697706,10.1532945 C14.9697706,10.1634339 14.9719558,10.1715629 14.9719558,10.1816586 C14.9962992,10.4249963 15.0449553,10.6277718 15.1321501,10.8325883 C15.2213771,11.0434797 15.3247905,11.1935346 15.4586266,11.3091153 C15.481047,11.3284764 15.5032139,11.3458708 15.525289,11.361399 C15.3860816,11.468536 15.3196072,11.5179308 15.2055298,11.6017559 C15.1323642,11.6554425 15.0452263,11.7193646 14.94395,11.7940162 C14.7230765,11.5871106 14.5507673,11.3270648 14.4001137,10.984671 C14.2216641,10.5791112 14.1263578,10.1735471 14.0979674,9.69498342 L14.0979674,9.69105002 C14.0716136,9.21249508 14.1182463,8.8008429 14.2500545,8.37500864 C14.3818627,7.94916563 14.5582845,7.6409444 14.813785,7.38745861 C15.06929,7.13399031 15.3268184,7.00623784 15.6370763,6.99001912 C15.6613322,6.98870799 15.6853347,6.98827095 15.709123,6.98827095 L15.7091362,6.98827969 Z M18.3434478,10.3083666 C18.9959552,10.3057443 19.7811624,10.5197693 20.731756,11.1309629 C21.3156605,11.5106715 21.7700031,11.5424053 22.8162176,11.9904939 L22.8175288,11.9909309 L22.8188399,11.991368 C23.322219,12.1979021 23.6176741,12.4671083 23.7620255,12.7505841 C23.906377,13.034073 23.9099039,13.3414857 23.7890786,13.6648724 C23.5474411,14.3116676 22.7761407,14.9923468 21.6937826,15.3303395 L21.6929085,15.3307766 L21.6920344,15.3312136 C21.1642857,15.5026793 20.7040867,15.8813302 20.1615484,16.1915706 C19.6190277,16.5017979 19.00512,16.7520102 18.1703739,16.7037212 C18.1703739,16.7037168 18.1703739,16.7037212 18.1703739,16.7037212 C17.4597396,16.6622893 17.0349499,16.4210539 16.650849,16.1123607 C16.2667437,15.8036631 15.9320245,15.4158517 15.4418966,15.1280491 L15.4405854,15.1271751 L15.4392743,15.126301 C14.6497885,14.6800742 14.2187709,14.163964 14.0834969,13.7165354 C13.9482185,13.2691068 14.075193,12.8871911 14.4668766,12.5936327 C14.9072645,12.2635986 15.2131825,12.0390976 15.4169632,11.8895453 C15.6194022,11.7409983 15.703625,11.685297 15.7680935,11.623394 C15.7684038,11.622957 15.7685305,11.622957 15.7689675,11.6225199 L15.7692735,11.6220829 C16.1001729,11.3088706 16.6276463,10.738226 17.4227569,10.4645313 C17.696421,10.3703264 18.001784,10.3095466 18.3435746,10.3081961 L18.3434478,10.3083666 Z M22.9062619,13.0069369 C22.6246829,13.0237631 22.3297828,13.1687002 21.9864013,13.3604054 C21.6430199,13.5521105 21.256878,13.7973406 20.8384079,14.0388338 C20.0014721,14.5218204 19.038047,14.9837283 18.0805918,14.9837283 C17.1216551,14.9837283 16.3555118,14.5408493 15.7808726,14.0854752 C15.4935509,13.8577838 15.2564149,13.6284404 15.0669561,13.4510265 C14.9722311,13.3623109 14.8900799,13.2867065 14.8134179,13.2276487 C14.7367734,13.1685909 14.6743853,13.1100357 14.5461303,13.1100357 L14.5400116,13.3795435 C14.5308337,13.4697233 14.5213935,13.4669437 14.5251084,13.4693999 C14.5310959,13.4733333 14.5608587,13.4835601 14.5955731,13.5103509 C14.6519344,13.5537495 14.7301609,13.6245375 14.8230067,13.7114832 C15.0086981,13.8853788 15.2554403,14.124464 15.5592255,14.3652012 C16.166796,14.8466668 17.0117515,15.3406363 18.0806093,15.3406363 C19.1509618,15.3406363 20.1636375,14.8403471 21.016875,14.3479598 C21.4434872,14.1017639 21.8309534,13.8560094 22.1604324,13.6720705 C22.4898897,13.4881185 22.7670895,13.3727781 22.9275766,13.3632068 L22.9062925,13.00695 L22.9062619,13.0069369 Z M23.8576858,14.2878093 C24.5685911,17.0901733 26.2220701,21.1378562 27.2848005,23.113201 C27.8496849,24.1612205 28.9735097,26.3878921 29.4590574,29.0706371 C29.7667148,29.0611969 30.1054855,29.1059065 30.4682673,29.1987042 C31.7377591,25.907589 29.3917525,22.3626165 28.3189832,21.375368 C27.8858722,20.9551061 27.8650557,20.7668098 28.0797669,20.7757081 C29.2436775,21.8049915 30.7716374,23.8752142 31.3275492,26.211938 C31.581035,27.2774436 31.6350799,28.3975886 31.3630809,29.5030663 C31.4961478,29.5583437 31.6312951,29.6184504 31.7682604,29.683286 C33.806037,30.6755779 34.5596721,31.5384567 34.1973186,32.716121 C34.0779748,32.7117506 33.960576,32.7126247 33.8460659,32.7152469 C33.8354021,32.7155572 33.8247819,32.715684 33.814118,32.716121 C34.1092104,31.7826203 33.4554837,31.0941179 31.7135031,30.305952 C29.9067264,29.5110511 28.4669839,29.5901387 28.2236507,31.2022427 C28.2080919,31.2867016 28.1955487,31.3727644 28.1860212,31.460029 C28.05104,31.506902 27.9153158,31.5667509 27.7792552,31.6412014 C26.9308557,32.1054213 26.4677896,32.9477371 26.2102393,33.9808403 C25.9529032,35.0131131 25.8791213,36.2610673 25.8081016,37.6639101 L25.8081016,37.6647842 C25.7647031,38.3701826 25.4746935,39.3242507 25.1805582,40.3347805 C22.2207839,42.446033 18.1128938,43.3607409 14.6251435,40.9805006 C14.3887768,40.6065916 14.1176344,40.2361221 13.8385378,39.8707355 C13.6603154,39.6373843 13.4772332,39.4054841 13.2952172,39.1768225 C13.6532528,39.1768225 13.9575843,39.1184771 14.2035442,39.0069433 C14.5094142,38.8682516 14.724322,38.6454901 14.8306462,38.3594969 C15.0432858,37.7875325 14.8297721,36.9806654 14.1489836,36.0592664 C13.4682956,35.137933 12.3154554,34.0981212 10.6214273,33.0592009 C10.6214273,33.0592009 10.621117,33.0592009 10.621117,33.0588906 C9.37658486,32.2846183 8.68057408,31.3355981 8.3547924,30.3051959 C8.02898013,29.2747018 8.07466439,28.1604089 8.32577265,27.0602631 C8.80774091,24.9485692 10.0461107,22.8947793 10.8362565,21.605909 C11.0489879,21.4493815 10.9122629,21.8964561 10.0363515,23.5230089 C9.25134103,25.0101357 7.78376323,28.4420972 9.79314068,31.1210705 C9.84684033,29.2145776 10.3021401,27.2701931 11.0664741,25.45145 C12.1797968,22.9278068 14.5084483,18.5514927 14.6933968,15.0635108 C14.7887555,15.1327561 15.1164383,15.3538525 15.2624505,15.4368866 C15.2627608,15.4373237 15.2628875,15.4373237 15.2633246,15.4373237 C15.6905181,15.6888908 16.0113611,16.0566244 16.426903,16.3905832 C16.8432709,16.7252019 17.3634237,17.0142238 18.149269,17.0600129 L18.149269,17.0600129 C19.066516,17.113092 19.7655905,16.8289912 20.3383504,16.5014745 C20.9102449,16.1744603 21.3671137,15.8125482 21.7999582,15.6712779 C21.8003952,15.6708409 21.8012693,15.6708409 21.8017063,15.6708409 C22.7163355,15.3848215 23.44356,14.8785842 23.857393,14.2881327 L23.8576858,14.2878093 Z M29.6669682,30.3312962 C30.0374289,30.329548 30.4861993,30.4530917 30.9774372,30.6728508 C32.2995623,31.2832227 32.713238,31.8063999 32.3522873,32.5749338 C32.0481219,33.1548918 30.7462669,34.0775407 29.8540319,33.8342075 C28.9435503,33.5989814 28.4994564,32.2869871 28.6474877,31.2953987 C28.7267763,30.6220356 29.1076387,30.3339097 29.6669682,30.3312962 L29.6669682,30.3312962 Z M28.1710786,32.1433306 C28.2458176,33.3559191 28.8457529,34.5926195 29.9067526,34.8602742 C31.0678224,35.1661922 32.7418469,34.16998 33.4486352,33.3574182 C33.5895689,33.3517803 33.7273516,33.3448313 33.8611658,33.3416409 C34.4811527,33.3266503 35.001157,33.3620509 35.5324588,33.8267253 L35.534207,33.8284735 L35.5359552,33.8302216 C35.9442465,34.1761336 36.1383204,34.8298385 36.3066481,35.5621545 C36.4749627,36.294475 36.6095636,37.0920505 37.11435,37.6602345 L37.115224,37.6611086 L37.1156611,37.6619827 C38.0861227,38.7388952 38.3980544,39.4668146 38.3715083,39.931406 C38.344936,40.3960279 38.008556,40.7409347 37.3873891,41.1155867 C36.1455928,41.864576 33.9453056,42.5158727 32.5399192,44.2181871 C31.3196037,45.6704378 29.8315635,46.4680352 28.5210638,46.5714617 C27.2105642,46.6748883 26.0799127,46.1309646 25.4133237,44.793071 L25.4115756,44.7900117 L25.4098274,44.7869524 C24.9962959,44.0002986 25.1685614,42.758852 25.5169207,41.4493706 C25.8652845,40.1398937 26.3657922,38.7953264 26.4327911,37.7024923 L26.4327911,37.7007442 L26.4327911,37.698996 C26.5036666,36.2987755 26.5820418,35.0759688 26.8172504,34.1324728 C27.0524633,33.1889769 27.4228236,32.5499829 28.0790545,32.1909116 C28.109604,32.1742165 28.139948,32.1584392 28.1701128,32.1435097 L28.1710786,32.1433306 Z M6.86074718,32.2348346 C6.95869322,32.2351449 7.06234705,32.2434006 7.17277507,32.2601394 C7.91559769,32.3726653 8.5633675,32.8920358 9.18746261,33.7385341 C9.8115621,34.5850455 10.3922762,35.7405823 10.9892352,37.0223812 L10.9901093,37.0241294 L10.9905463,37.0258776 C11.4702594,38.0271115 12.4825418,39.128044 13.3403902,40.2511564 C14.1982341,41.3742689 14.8621527,42.5016163 14.7756966,43.3644732 L14.7753863,43.3684066 L14.775076,43.37234 C14.6632363,44.843978 13.8330966,45.6451198 12.5587449,45.9361914 C11.2847734,46.2271625 9.55771794,45.9379396 7.83269472,45.035587 L7.83094655,45.035587 C5.9224477,44.0247687 3.65205856,44.1251622 2.19566909,43.8209924 C1.46727769,43.6688572 0.99200058,43.44013 0.773862951,43.0151698 C0.55571221,42.5902315 0.550839164,41.8488511 1.01440785,40.5847437 L1.01659307,40.5791059 L1.01834125,40.573468 C1.24759292,39.8663213 1.07793226,39.0925822 0.96663015,38.3663367 C0.855328038,37.6400911 0.800894151,36.9795116 1.04888192,36.5190765 L1.05019305,36.5168913 L1.05150418,36.514706 C1.36900824,35.9026821 1.83472718,35.683902 2.41273159,35.4765375 C2.990736,35.2691556 3.67612223,35.1062953 4.21734934,34.5638925 L4.21997161,34.5612703 L4.22259387,34.558648 C4.72293985,34.0308163 5.09877623,33.3691834 5.53863963,32.8995879 C5.90977341,32.5033678 6.28118253,32.2407652 6.84099715,32.2368755 L6.86053303,32.2368755 L6.86074718,32.2348346 Z"></path> <path d="M58.5014648,40 L58.5014648,6.7578125 L65.4194336,6.7578125 L65.4194336,35.2832031 L80.4008789,35.2832031 L80.4008789,40 L58.5014648,40 L58.5014648,40 L58.5014648,40 Z M86.2524414,40 L86.2524414,15.3378906 L92.9008789,15.3378906 L92.9008789,40 L86.2524414,40 L86.2524414,40 L86.2524414,40 Z M86.2524414,11.1826172 L86.2524414,5.63476562 L92.9008789,5.63476562 L92.9008789,11.1826172 L86.2524414,11.1826172 L86.2524414,11.1826172 L86.2524414,11.1826172 Z M100.211426,40 L100.211426,15.3378906 L106.859863,15.3378906 L106.859863,19.9873047 C109.031098,16.513329 111.8312,14.7763672 115.260254,14.7763672 C117.461437,14.7763672 119.198399,15.4726493 120.471191,16.8652344 C121.743984,18.2578195 122.380371,20.1594932 122.380371,22.5703125 L122.380371,40 L115.731934,40 L115.731934,24.2099609 C115.731934,21.4098167 114.803557,20.0097656 112.946777,20.0097656 C110.835439,20.0097656 108.806488,21.4996596 106.859863,24.4794922 L106.859863,40 L100.211426,40 L100.211426,40 L100.211426,40 Z M145.672363,40 L145.672363,35.3505859 C143.516102,38.8245616 140.716,40.5615234 137.271973,40.5615234 C135.07079,40.5615234 133.333828,39.8652413 132.061035,38.4726562 C130.788242,37.0800712 130.151855,35.1783975 130.151855,32.7675781 L130.151855,15.3378906 L136.800293,15.3378906 L136.800293,31.1279297 C136.800293,33.9280739 137.736156,35.328125 139.60791,35.328125 C141.704275,35.328125 143.725739,33.838231 145.672363,30.8583984 L145.672363,15.3378906 L152.320801,15.3378906 L152.320801,40 L145.672363,40 L145.672363,40 L145.672363,40 Z M158.003418,40 L166.471191,27.6240234 L158.362793,15.3378906 L165.932129,15.3378906 L171.23291,23.1542969 L176.309082,15.3378906 L181.699707,15.3378906 L173.973145,27.4443359 L182.26123,40 L174.691895,40 L169.166504,31.8466797 L163.506348,40 L158.003418,40 L158.003418,40 L158.003418,40 Z"></path> </g> </g> </g> </svg>
</a>
</div>
<div class="search">
<ul class="search-list" id="result">
<!-- <li><a href="#"><strong>find</strong> - 指定目录下查找文件。</a></li> -->
</ul>
<input type="text" class="query" id="query" autocomplete="off" autofocus="autofocus" placeholder="Linux 命令搜索"/>
<div class="enter-input">
<input type="hidden" id="current_path" value="/c/find.html">
<button id="search_btn">搜索</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="../js/copy-to-clipboard.js"></script>
<div class="markdown-body">
<span class="edit_btn">
<a target="_blank" href="https://github.com/jaywcjlove/linux-command/edit/master/command/find.md">纠正错误</a>
<span class="split"></span>
<a target="_blank" href="https://github.com/jaywcjlove/linux-command/edit/master/command/find.md">添加实例</a>
</span>
<dark-mode style="position: fixed; top: 8px; left: 10px; z-index: 999;;display: none;" dark="Dark" light="Light"></dark-mode><script>const t=document;const e="_dark_mode_theme_";const s="permanent";const o="colorschemechange";const i="permanentcolorscheme";const h="light";const r="dark";const n=(t,e,s=e)=>{Object.defineProperty(t,s,{enumerable:true,get(){const t=this.getAttribute(e);return t===null?"":t},set(t){this.setAttribute(e,t)}})};const c=(t,e,s=e)=>{Object.defineProperty(t,s,{enumerable:true,get(){return this.hasAttribute(e)},set(t){if(t){this.setAttribute(e,"")}else{this.removeAttribute(e)}}})};class a extends HTMLElement{static get observedAttributes(){return["mode",h,r,s]}LOCAL_NANE=e;constructor(){super();this.t()}connectedCallback(){n(this,"mode");n(this,r);n(this,h);c(this,s);const a=localStorage.getItem(e);if(a&&[h,r].includes(a)){this.mode=a;this.permanent=true}if(this.permanent&&!a){localStorage.setItem(e,this.mode)}const l=[h,r].includes(a);if(this.permanent&&a){this.o()}else{if(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches){this.mode=r;this.o()}if(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches){this.mode=h;this.o()}}if(!this.permanent&&!l){window.matchMedia("(prefers-color-scheme: light)").onchange=t=>{this.mode=t.matches?h:r;this.o()};window.matchMedia("(prefers-color-scheme: dark)").onchange=t=>{this.mode=t.matches?r:h;this.o()}}const d=new MutationObserver(((s,h)=>{this.mode=t.documentElement.dataset.colorMode;if(this.permanent&&l){localStorage.setItem(e,this.mode);this.i(i,{permanent:this.permanent})}this.h();this.i(o,{colorScheme:this.mode})}));d.observe(t.documentElement,{attributes:true});this.i(o,{colorScheme:this.mode});this.h()}attributeChangedCallback(t,s,o){if(t==="mode"&&s!==o&&[h,r].includes(o)){const t=localStorage.getItem(e);if(this.mode===t){this.mode=o;this.h();this.o()}else if(this.mode&&this.mode!==t){this.h();this.o()}}else if((t===h||t===r)&&s!==o){this.h()}if(t==="permanent"&&typeof this.permanent==="boolean"){this.permanent?localStorage.setItem(e,this.mode):localStorage.removeItem(e)}}o(){t.documentElement.setAttribute("data-color-mode",this.mode)}h(){this.icon.textContent=this.mode===h?"🌒":"🌞";this.text.textContent=this.mode===h?this.getAttribute(r):this.getAttribute(h)}t(){var s=this.attachShadow({mode:"open"});this.label=t.createElement("span");this.label.setAttribute("class","wrapper");this.label.onclick=()=>{this.mode=this.mode===h?r:h;if(this.permanent){localStorage.setItem(e,this.mode)}this.o();this.h()};s.appendChild(this.label);this.icon=t.createElement("span");this.label.appendChild(this.icon);this.text=t.createElement("span");this.label.appendChild(this.text);const o=`
[data-color-mode*='dark'], [data-color-mode*='dark'] body {
color-scheme: dark;
--color-theme-bg: #0d1117;
--color-theme-text: #c9d1d9;
background-color: var(--color-theme-bg);
color: var(--color-theme-text);
}
[data-color-mode*='light'], [data-color-mode*='light'] body {
color-scheme: light;
--color-theme-bg: #fff;
--color-theme-text: #24292f;
background-color: var(--color-theme-bg);
color: var(--color-theme-text);
}`;const i="_dark_mode_style_";const n=t.getElementById(i);if(!n){var c=t.createElement("style");c.id=i;c.textContent=o;t.head.appendChild(c)}var a=t.createElement("style");a.textContent=`
.wrapper { cursor: pointer; user-select: none; position: relative; }
.wrapper > span + span { margin-left: .4rem; }
`;s.appendChild(a)}i(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:true,composed:true,detail:e}))}}customElements.define("dark-mode",a);</script><script>const __TEMPLATE__ = document.createElement('template');
__TEMPLATE__.innerHTML = `
<style>
markdown-style h1:hover a.anchor .octicon-link:before,
markdown-style h2:hover a.anchor .octicon-link:before,
markdown-style h3:hover a.anchor .octicon-link:before,
markdown-style h4:hover a.anchor .octicon-link:before,
markdown-style h5:hover a.anchor .octicon-link:before,
markdown-style h6:hover a.anchor .octicon-link:before {
width: 16px;
height: 16px;
content: ' ';
display: inline-block;
background-color: currentColor;
-webkit-mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' version='1.1' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>");
mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' version='1.1' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>");
}
[data-color-mode*='light'], [data-color-mode*='light'] body, markdown-style[theme*='light'] { --color-prettylights-syntax-comment: #6e7781; --color-prettylights-syntax-constant: #0550ae; --color-prettylights-syntax-entity: #8250df; --color-prettylights-syntax-storage-modifier-import: #24292f; --color-prettylights-syntax-entity-tag: #116329; --color-prettylights-syntax-keyword: #cf222e; --color-prettylights-syntax-string: #0a3069; --color-prettylights-syntax-variable: #953800; --color-prettylights-syntax-brackethighlighter-unmatched: #82071e; --color-prettylights-syntax-invalid-illegal-text: #f6f8fa; --color-prettylights-syntax-invalid-illegal-bg: #82071e; --color-prettylights-syntax-carriage-return-text: #f6f8fa; --color-prettylights-syntax-carriage-return-bg: #cf222e; --color-prettylights-syntax-string-regexp: #116329; --color-prettylights-syntax-markup-list: #3b2300; --color-prettylights-syntax-markup-heading: #0550ae; --color-prettylights-syntax-markup-italic: #24292f; --color-prettylights-syntax-markup-bold: #24292f; --color-prettylights-syntax-markup-deleted-text: #82071e; --color-prettylights-syntax-markup-deleted-bg: #FFEBE9; --color-prettylights-syntax-markup-inserted-text: #116329; --color-prettylights-syntax-markup-inserted-bg: #dafbe1; --color-prettylights-syntax-markup-changed-text: #953800; --color-prettylights-syntax-markup-changed-bg: #ffd8b5; --color-prettylights-syntax-markup-ignored-text: #eaeef2; --color-prettylights-syntax-markup-ignored-bg: #0550ae; --color-prettylights-syntax-meta-diff-range: #8250df; --color-prettylights-syntax-brackethighlighter-angle: #57606a; --color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f; --color-prettylights-syntax-constant-other-reference-link: #0a3069; --color-fg-default: #24292f; --color-fg-muted: #57606a; --color-fg-subtle: #6e7781; --color-canvas-default: #ffffff; --color-canvas-subtle: #f6f8fa; --color-border-default: #d0d7de; --color-border-muted: hsla(210,18%,87%,1); --color-neutral-muted: rgba(175,184,193,0.2); --color-accent-fg: #0969da; --color-accent-emphasis: #0969da; --color-attention-subtle: #fff8c5; --color-danger-fg: #cf222e; } [data-color-mode*='dark'], [data-color-mode*='dark'] body, markdown-style[theme*='dark'] { --color-prettylights-syntax-comment: #8b949e; --color-prettylights-syntax-constant: #79c0ff; --color-prettylights-syntax-entity: #d2a8ff; --color-prettylights-syntax-storage-modifier-import: #c9d1d9; --color-prettylights-syntax-entity-tag: #7ee787; --color-prettylights-syntax-keyword: #ff7b72; --color-prettylights-syntax-string: #a5d6ff; --color-prettylights-syntax-variable: #ffa657; --color-prettylights-syntax-brackethighlighter-unmatched: #f85149; --color-prettylights-syntax-invalid-illegal-text: #f0f6fc; --color-prettylights-syntax-invalid-illegal-bg: #8e1519; --color-prettylights-syntax-carriage-return-text: #f0f6fc; --color-prettylights-syntax-carriage-return-bg: #b62324; --color-prettylights-syntax-string-regexp: #7ee787; --color-prettylights-syntax-markup-list: #f2cc60; --color-prettylights-syntax-markup-heading: #1f6feb; --color-prettylights-syntax-markup-italic: #c9d1d9; --color-prettylights-syntax-markup-bold: #c9d1d9; --color-prettylights-syntax-markup-deleted-text: #ffdcd7; --color-prettylights-syntax-markup-deleted-bg: #67060c; --color-prettylights-syntax-markup-inserted-text: #aff5b4; --color-prettylights-syntax-markup-inserted-bg: #033a16; --color-prettylights-syntax-markup-changed-text: #ffdfb6; --color-prettylights-syntax-markup-changed-bg: #5a1e02; --color-prettylights-syntax-markup-ignored-text: #c9d1d9; --color-prettylights-syntax-markup-ignored-bg: #1158c7; --color-prettylights-syntax-meta-diff-range: #d2a8ff; --color-prettylights-syntax-brackethighlighter-angle: #8b949e; --color-prettylights-syntax-sublimelinter-gutter-mark: #484f58; --color-prettylights-syntax-constant-other-reference-link: #a5d6ff; --color-fg-default: #c9d1d9; --color-fg-muted: #8b949e; --color-fg-subtle: #484f58; --color-canvas-default: #0d1117; --color-canvas-subtle: #161b22; --color-border-default: #30363d; --color-border-muted: #21262d; --color-neutral-muted: rgba(110,118,129,0.4); --color-accent-fg: #58a6ff; --color-accent-emphasis: #1f6feb; --color-attention-subtle: rgba(187,128,9,0.15); --color-danger-fg: #f85149; } markdown-style { display: block; -webkit-text-size-adjust: 100%; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"; font-size: 16px; line-height: 1.5; word-wrap: break-word; color: var(--color-fg-default); background-color: var(--color-canvas-default); } markdown-style details, markdown-style figcaption, markdown-style figure { display: block; } markdown-style summary { display: list-item; } markdown-style [hidden] { display: none !important; } markdown-style a { background-color: transparent; color: var(--color-accent-fg); text-decoration: none; } markdown-style a:active, markdown-style a:hover { outline-width: 0; } markdown-style abbr[title] { border-bottom: none; text-decoration: underline dotted; } markdown-style b, markdown-style strong { font-weight: 600; } markdown-style dfn { font-style: italic; } markdown-style h1 { margin: .67em 0; font-weight: 600; padding-bottom: .3em; font-size: 2em; border-bottom: 1px solid var(--color-border-muted); } markdown-style mark { background-color: var(--color-attention-subtle); color: var(--color-text-primary); } markdown-style small { font-size: 90%; } markdown-style sub, markdown-style sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } markdown-style sub { bottom: -0.25em; } markdown-style sup { top: -0.5em; } markdown-style img { border-style: none; max-width: 100%; box-sizing: content-box; background-color: var(--color-canvas-default); } markdown-style code, markdown-style kbd, markdown-style pre, markdown-style samp { font-family: monospace,monospace; font-size: 1em; } markdown-style figure { margin: 1em 40px; } markdown-style hr { box-sizing: content-box; overflow: hidden; background: transparent; border-bottom: 1px solid var(--color-border-muted); height: .25em; padding: 0; margin: 24px 0; background-color: var(--color-border-default); border: 0; } markdown-style input { font: inherit; margin: 0; overflow: visible; font-family: inherit; font-size: inherit; line-height: inherit; } markdown-style [type=button], markdown-style [type=reset], markdown-style [type=submit] { -webkit-appearance: button; } markdown-style [type=button]::-moz-focus-inner, markdown-style [type=reset]::-moz-focus-inner, markdown-style [type=submit]::-moz-focus-inner { border-style: none; padding: 0; } markdown-style [type=button]:-moz-focusring, markdown-style [type=reset]:-moz-focusring, markdown-style [type=submit]:-moz-focusring { outline: 1px dotted ButtonText; } markdown-style [type=checkbox], markdown-style [type=radio] { box-sizing: border-box; padding: 0; } markdown-style [type=number]::-webkit-inner-spin-button, markdown-style [type=number]::-webkit-outer-spin-button { height: auto; } markdown-style [type=search] { -webkit-appearance: textfield; outline-offset: -2px; } markdown-style [type=search]::-webkit-search-cancel-button, markdown-style [type=search]::-webkit-search-decoration { -webkit-appearance: none; } markdown-style ::-webkit-input-placeholder { color: inherit; opacity: .54; } markdown-style ::-webkit-file-upload-button { -webkit-appearance: button; font: inherit; } markdown-style a:hover { text-decoration: underline; } markdown-style hr::before { display: table; content: ""; } markdown-style hr::after { display: table; clear: both; content: ""; } markdown-style table { border-spacing: 0; border-collapse: collapse; display: block; width: max-content; max-width: 100%; overflow: auto; } markdown-style td, markdown-style th { padding: 0; } markdown-style details summary { cursor: pointer; } markdown-style details:not([open])>*:not(summary) { display: none !important; } markdown-style kbd { display: inline-block; padding: 3px 5px; font: 11px ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; line-height: 10px; color: var(--color-fg-default); vertical-align: middle; background-color: var(--color-canvas-subtle); border: solid 1px var(--color-neutral-muted); border-bottom-color: var(--color-neutral-muted); border-radius: 6px; box-shadow: inset 0 -1px 0 var(--color-neutral-muted); } markdown-style h1, markdown-style h2, markdown-style h3, markdown-style h4, markdown-style h5, markdown-style h6 { margin-top: 24px; margin-bottom: 16px; font-weight: 600; line-height: 1.25; } markdown-style h2 { font-weight: 600; padding-bottom: .3em; font-size: 1.5em; border-bottom: 1px solid var(--color-border-muted); } markdown-style h3 { font-weight: 600; font-size: 1.25em; } markdown-style h4 { font-weight: 600; font-size: 1em; } markdown-style h5 { font-weight: 600; font-size: .875em; } markdown-style h6 { font-weight: 600; font-size: .85em; color: var(--color-fg-muted); } markdown-style p { margin-top: 0; margin-bottom: 10px; } markdown-style blockquote { margin: 0; padding: 0 1em; color: var(--color-fg-muted); border-left: .25em solid var(--color-border-default); } markdown-style ul, markdown-style ol { margin-top: 0; margin-bottom: 0; padding-left: 2em; } markdown-style ol ol, markdown-style ul ol { list-style-type: lower-roman; } markdown-style ul ul ol, markdown-style ul ol ol, markdown-style ol ul ol, markdown-style ol ol ol { list-style-type: lower-alpha; } markdown-style dd { margin-left: 0; } markdown-style tt, markdown-style code { font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; font-size: 12px; } markdown-style pre { margin-top: 0; margin-bottom: 0; font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; font-size: 12px; word-wrap: normal; } markdown-style .octicon { display: inline-block; overflow: visible !important; vertical-align: text-bottom; fill: currentColor; } markdown-style ::placeholder { color: var(--color-fg-subtle); opacity: 1; } markdown-style input::-webkit-outer-spin-button, markdown-style input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; appearance: none; }
markdown-style .token.comment, markdown-style .token.prolog, markdown-style .token.doctype, markdown-style .token.cdata { color: var(--color-prettylights-syntax-comment); } markdown-style .token.namespace { opacity: 0.7; } markdown-style .token.tag, markdown-style .token.selector, markdown-style .token.constant, markdown-style .token.symbol, markdown-style .token.deleted { color: var(--color-prettylights-syntax-entity-tag); } markdown-style .token.maybe-class-name { color: var(--color-prettylights-syntax-variable); } markdown-style .token.property-access, markdown-style .token.operator, markdown-style .token.boolean, markdown-style .token.number, markdown-style .token.selector markdown-style .token.class, markdown-style .token.attr-name, markdown-style .token.string, markdown-style .token.char, markdown-style .token.builtin { color: var(--color-prettylights-syntax-constant); } markdown-style .token.deleted { color: var(--color-prettylights-syntax-markup-deleted-text); } markdown-style .token.property { color: var(--color-prettylights-syntax-constant); } markdown-style .token.punctuation { color: var(--color-prettylights-syntax-markup-bold); } markdown-style .token.function { color: var(--color-prettylights-syntax-entity); } markdown-style .code-line .token.deleted { background-color: var(--color-prettylights-syntax-markup-deleted-bg); } markdown-style .token.inserted { color: var(--color-prettylights-syntax-markup-inserted-text); } markdown-style .code-line .token.inserted { background-color: var(--color-prettylights-syntax-markup-inserted-bg); } markdown-style .token.variable { color: var(--color-prettylights-syntax-constant); } markdown-style .token.entity, markdown-style .token.url, .language-css markdown-style .token.string, .style markdown-style .token.string { color: var(--color-prettylights-syntax-string); } markdown-style .token.color, markdown-style .token.atrule, markdown-style .token.attr-value, markdown-style .token.function, markdown-style .token.class-name { color: var(--color-prettylights-syntax-string); } markdown-style .token.rule, markdown-style .token.regex, markdown-style .token.important, markdown-style .token.keyword { color: var(--color-prettylights-syntax-keyword); } markdown-style .token.coord { color: var(--color-prettylights-syntax-meta-diff-range); } markdown-style .token.important, markdown-style .token.bold { font-weight: bold; } markdown-style .token.italic { font-style: italic; } markdown-style .token.entity { cursor: help; }
markdown-style [data-catalyst] { display: block; } markdown-style g-emoji { font-family: "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"; font-size: 1em; font-style: normal !important; font-weight: 400; line-height: 1; vertical-align: -0.075em; } markdown-style g-emoji img { width: 1em; height: 1em; } markdown-style::before { display: table; content: ""; } markdown-style::after { display: table; clear: both; content: ""; } markdown-style>*:first-child { margin-top: 0 !important; } markdown-style>*:last-child { margin-bottom: 0 !important; } markdown-style a:not([href]) { color: inherit; text-decoration: none; } markdown-style .absent { color: var(--color-danger-fg); } markdown-style a.anchor { float: left; padding-right: 4px; margin-left: -20px; line-height: 1; } markdown-style a.anchor:focus { outline: none; } markdown-style p, markdown-style blockquote, markdown-style ul, markdown-style ol, markdown-style dl, markdown-style table, markdown-style pre, markdown-style details { margin-top: 0; margin-bottom: 16px; } markdown-style blockquote>:first-child { margin-top: 0; } markdown-style blockquote>:last-child { margin-bottom: 0; } markdown-style sup>a::before { content: "["; } markdown-style sup>a::after { content: "]"; }
markdown-style .octicon-video { border: 1px solid #d0d7de !important; border-radius: 6px !important; display: block; } markdown-style .octicon-video summary { border-bottom: 1px solid #d0d7de !important; padding: 8px 16px !important; cursor: pointer; } markdown-style .octicon-video > video { display: block !important; max-width: 100% !important; padding: 2px; box-sizing: border-box; border-bottom-right-radius: 6px !important; border-bottom-left-radius: 6px !important; } markdown-style details.octicon-video:not([open])>*:not(summary) { display: none !important; } markdown-style details.octicon-video:not([open]) > summary { border-bottom: 0 !important; } markdown-style h1 .octicon-link, markdown-style h2 .octicon-link, markdown-style h3 .octicon-link, markdown-style h4 .octicon-link, markdown-style h5 .octicon-link, markdown-style h6 .octicon-link { color: var(--color-fg-default); vertical-align: middle; visibility: hidden; } markdown-style h1:hover .anchor, markdown-style h2:hover .anchor, markdown-style h3:hover .anchor, markdown-style h4:hover .anchor, markdown-style h5:hover .anchor, markdown-style h6:hover .anchor { text-decoration: none; } markdown-style h1:hover .anchor .octicon-link, markdown-style h2:hover .anchor .octicon-link, markdown-style h3:hover .anchor .octicon-link, markdown-style h4:hover .anchor .octicon-link, markdown-style h5:hover .anchor .octicon-link, markdown-style h6:hover .anchor .octicon-link { visibility: visible; } markdown-style h1 tt, markdown-style h1 code, markdown-style h2 tt, markdown-style h2 code, markdown-style h3 tt, markdown-style h3 code, markdown-style h4 tt, markdown-style h4 code, markdown-style h5 tt, markdown-style h5 code, markdown-style h6 tt, markdown-style h6 code { padding: 0 .2em; font-size: inherit; } markdown-style ul.no-list, markdown-style ol.no-list { padding: 0; list-style-type: none; } markdown-style ol[type="1"] { list-style-type: decimal; } markdown-style ol[type=a] { list-style-type: lower-alpha; } markdown-style ol[type=i] { list-style-type: lower-roman; } markdown-style div>ol:not([type]) { list-style-type: decimal; } markdown-style ul ul, markdown-style ul ol, markdown-style ol ol, markdown-style ol ul { margin-top: 0; margin-bottom: 0; } markdown-style li>p { margin-top: 16px; } markdown-style li+li { margin-top: .25em; } markdown-style dl { padding: 0; } markdown-style dl dt { padding: 0; margin-top: 16px; font-size: 1em; font-style: italic; font-weight: 600; } markdown-style dl dd { padding: 0 16px; margin-bottom: 16px; } markdown-style table th { font-weight: 600; } markdown-style table th, markdown-style table td { padding: 6px 13px; border: 1px solid var(--color-border-default); } markdown-style table tr { background-color: var(--color-canvas-default); border-top: 1px solid var(--color-border-muted); } markdown-style table tr:nth-child(2n) { background-color: var(--color-canvas-subtle); } markdown-style table img { background-color: transparent; vertical-align: middle; } markdown-style img[align=right] { padding-left: 20px; } markdown-style img[align=left] { padding-right: 20px; } markdown-style .emoji { max-width: none; vertical-align: text-top; background-color: transparent; } markdown-style span.frame { display: block; overflow: hidden; } markdown-style span.frame>span { display: block; float: left; width: auto; padding: 7px; margin: 13px 0 0; overflow: hidden; border: 1px solid var(--color-border-default); } markdown-style span.frame span img { display: block; float: left; } markdown-style span.frame span span { display: block; padding: 5px 0 0; clear: both; color: var(--color-fg-default); } markdown-style span.align-center { display: block; overflow: hidden; clear: both; } markdown-style span.align-center>span { display: block; margin: 13px auto 0; overflow: hidden; text-align: center; } markdown-style span.align-center span img { margin: 0 auto; text-align: center; } markdown-style span.align-right { display: block; overflow: hidden; clear: both; } markdown-style span.align-right>span { display: block; margin: 13px 0 0; overflow: hidden; text-align: right; } markdown-style span.align-right span img { margin: 0; text-align: right; } markdown-style span.float-left { display: block; float: left; margin-right: 13px; overflow: hidden; } markdown-style span.float-left span { margin: 13px 0 0; } markdown-style span.float-right { display: block; float: right; margin-left: 13px; overflow: hidden; } markdown-style span.float-right>span { display: block; margin: 13px auto 0; overflow: hidden; text-align: right; } markdown-style code, markdown-style tt { padding: .2em .4em; margin: 0; font-size: 85%; background-color: var(--color-neutral-muted); border-radius: 6px; } markdown-style code br, markdown-style tt br { display: none; } markdown-style del code { text-decoration: inherit; } markdown-style pre code { font-size: 100%; } markdown-style pre>code { padding: 0; margin: 0; word-break: normal; white-space: pre; background: transparent; border: 0; } markdown-style pre { position: relative; font-size: 85%; line-height: 1.45; background-color: var(--color-canvas-subtle); border-radius: 6px; } markdown-style pre code, markdown-style pre tt { display: inline; max-width: auto; padding: 0; margin: 0; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; } markdown-style pre > code { padding: 16px; overflow: auto; display: block; } markdown-style .csv-data td, markdown-style .csv-data th { padding: 5px; overflow: hidden; font-size: 12px; line-height: 1; text-align: left; white-space: nowrap; } markdown-style .csv-data .blob-num { padding: 10px 8px 9px; text-align: right; background: var(--color-canvas-default); border: 0; } markdown-style .csv-data tr { border-top: 0; } markdown-style .csv-data th { font-weight: 600; background: var(--color-canvas-subtle); border-top: 0; } markdown-style .footnotes { font-size: 12px; color: var(--color-fg-muted); border-top: 1px solid var(--color-border-default); } markdown-style .footnotes ol { padding-left: 16px; } markdown-style .footnotes li { position: relative; } markdown-style .footnotes li:target::before { position: absolute; top: -8px; right: -8px; bottom: -8px; left: -24px; pointer-events: none; content: ""; border: 2px solid var(--color-accent-emphasis); border-radius: 6px; } markdown-style .footnotes li:target { color: var(--color-fg-default); } markdown-style .footnotes .data-footnote-backref g-emoji { font-family: monospace; } markdown-style .task-list-item { list-style-type: none; } markdown-style .task-list-item label { font-weight: 400; } markdown-style .task-list-item.enabled label { cursor: pointer; } markdown-style .task-list-item+.task-list-item { margin-top: 3px; } markdown-style .task-list-item .handle { display: none; } markdown-style .task-list-item-checkbox, markdown-style input[type="checkbox"] { margin: 0 .2em .25em -1.6em; vertical-align: middle; } markdown-style .contains-task-list:dir(rtl) .task-list-item-checkbox, markdown-style .contains-task-list:dir(rtl) input[type="checkbox"] { margin: 0 -1.6em .25em .2em; } markdown-style ::-webkit-calendar-picker-indicator { filter: invert(50%); }
</style>
<slot></slot>
`;
class MarkdownStyle extends HTMLElement {
constructor() {
super();
this.shadow = this.attachShadow({ mode: 'open' });
this.shadow.appendChild(__TEMPLATE__.content.cloneNode(true));
const style = Array.prototype.slice
.call(this.shadow.children)
.find((item) => item.tagName === 'STYLE');
if (style) {
const id = '__MARKDOWN_STYLE__';
const findStyle = document.getElementById(id);
if (!findStyle) {
style.id = id;
document.head.append(style);
}
}
}
get theme() {
const value = this.getAttribute('theme');
return value === null ? '' : value;
}
set theme(name) {
this.setAttribute('theme', name);
}
connectedCallback() {
if (!this.theme) {
const { colorMode } = document.documentElement.dataset;
this.theme = colorMode;
const observer = new MutationObserver((mutationsList, observer) => {
this.theme = document.documentElement.dataset.colorMode;
});
observer.observe(document.documentElement, { attributes: true });
window.matchMedia('(prefers-color-scheme: light)').onchange = (event) => {
this.theme = event.matches ? 'light' : 'dark';
};
window.matchMedia('(prefers-color-scheme: dark)').onchange = (event) => {
this.theme = event.matches ? 'dark' : 'light';
};
}
}
}
customElements.define('markdown-style', MarkdownStyle);</script><markdown-style style="max-width: 960px; margin: 0 auto 60px auto; padding: 8px;" class="markdown-style">
<h1 id="find"><a class="anchor" aria-hidden="true" tabindex="-1" href="#find"><span class="octicon octicon-link"></span></a>find</h1>
<p>在指定目录下查找文件</p>
<h2 id="解释"><a class="anchor" aria-hidden="true" tabindex="-1" href="#解释"><span class="octicon octicon-link"></span></a>解释</h2>
<p>从每个指定的起始点 (目录) 开始,搜索以该点为根的目录树,并按照运算符优先级规则<strong>从左至右</strong>评估给定的表达式,直到结果确定,此时<code>find</code>会继续处理下一个文件名。</p>
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
<p>本文列出的选项指的是<strong>表达式列表中的选项</strong>。这些选项控制了<code>find</code>的行为,需在<strong>最后一个路径名之后</strong>立即指定。</p>
<p>五个真实选项: <code>-H、-L、-P、-D 和 -O</code>。如果出现,<strong>必须位于第一个路径名之前</strong>。关于这部分内容本文不做描述,具体内容可参考<a href="https://man7.org/linux/man-pages/man1/find.1.html#top_of_page">man7.org中的find</a></p>
<p>如果使用该命令时,不设置任何参数,则<code>find</code>命令将在当前目录下查找子目录与文件,并且将查找到的子目录和文件全部进行显示。等效于以下命令:</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-print</span>
</span></code><div onclick="copied(this)" data-code="find . -print
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h2 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h2>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token punctuation">[</span>-H<span class="token punctuation">]</span> <span class="token punctuation">[</span>-L<span class="token punctuation">]</span> <span class="token punctuation">[</span>-P<span class="token punctuation">]</span> <span class="token punctuation">[</span>-D debugopts<span class="token punctuation">]</span> <span class="token punctuation">[</span>-Olevel<span class="token punctuation">]</span> <span class="token punctuation">[</span>起始点<span class="token punctuation">..</span>.<span class="token punctuation">]</span> <span class="token punctuation">[</span>表达式<span class="token punctuation">]</span>
</span></code><div onclick="copied(this)" data-code="find [-H] [-L] [-P] [-D debugopts] [-Olevel] [起始点...] [表达式]
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>忽略真实选项后 (更为常见):</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token punctuation">[</span>起始点<span class="token punctuation">..</span>.<span class="token punctuation">]</span> <span class="token punctuation">[</span>表达式<span class="token punctuation">]</span>
</span></code><div onclick="copied(this)" data-code="find [起始点...] [表达式]
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h2 id="表达式分类"><a class="anchor" aria-hidden="true" tabindex="-1" href="#表达式分类"><span class="octicon octicon-link"></span></a>表达式分类</h2>
<p>起始点(列表)之后的部分是表达式。这是一种<strong>查询规范</strong>,描述了我们如何匹配文件(返回<strong></strong>或者<strong></strong>)以及对匹配到的文件进行何种操作。表达式由一系列元素组成:</p>
<ul>
<li>测试Tests测试返回一个真或假值通常基于我们正在考虑的文件的某个属性。例如<code>-empty</code>测试仅在当前文件为空时为真。</li>
<li>操作Actions操作具有副作用例如在标准输出上打印内容并返回真或假通常基于它们是否成功。例如<code>-print</code>操作会在标准输出上打印当前文件的名称。</li>
<li>全局Global全局选项影响命令行中任何部分指定的测试和操作的执行。全局选项始终返回真值。例如<code>-depth</code>选项使find以深度优先的顺序遍历文件系统。</li>
<li>位置Positional位置选项仅影响其后的测试或操作。位置选项始终返回真值。例如<code>-regextype</code>选项是位置选项,用于指定命令行中后续正则表达式所使用的正则表达式方言。</li>
<li>操作符Operators运算符将表达式中的其他项连接起来。例如它们包括<code>-o</code>(表示逻辑或)和<code>-a</code>(表示逻辑与)。如果缺少运算符,则默认使用<code>-a</code></li>
</ul>
<h2 id="表达式选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#表达式选项"><span class="octicon octicon-link"></span></a>表达式选项</h2>
<h3 id="测试选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#测试选项"><span class="octicon octicon-link"></span></a>测试选项</h3>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">-amin<span class="token operator">&#x3C;</span>分钟<span class="token operator">></span>:查找在指定时间曾被存取过的文件或目录,单位以分钟计算;
</span><span class="code-line line-number" line="2">-anewer<span class="token operator">&#x3C;</span>参考文件或目录<span class="token operator">></span>:查找其存取时间较指定文件或目录的存取时间更接近现在的文件或目录;
</span><span class="code-line line-number" line="3">-atime<span class="token operator">&#x3C;</span><span class="token number">24</span>小时数<span class="token operator">></span>查找在指定时间曾被存取过的文件或目录单位以24小时计算
</span><span class="code-line line-number" line="4">-cmin<span class="token operator">&#x3C;</span>分钟<span class="token operator">></span>:查找在指定时间之时被更改过的文件或目录;
</span><span class="code-line line-number" line="5">-cnewer<span class="token operator">&#x3C;</span>参考文件或目录<span class="token operator">></span>查找其更改时间较指定文件或目录的更改时间更接近现在的文件或目录;
</span><span class="code-line line-number" line="6">-ctime<span class="token operator">&#x3C;</span><span class="token number">24</span>小时数<span class="token operator">></span>查找在指定时间之时被更改的文件或目录单位以24小时计算
</span><span class="code-line line-number" line="7">-empty寻找文件大小为0 Byte的文件或目录下没有任何子目录或文件的空目录
</span><span class="code-line line-number" line="8"><span class="token parameter variable">-executable</span> 匹配当前用户可执行的文件和可搜索的目录。
</span><span class="code-line line-number" line="9">-false将find指令的回传值皆设为False
</span><span class="code-line line-number" line="10">-fstype<span class="token operator">&#x3C;</span>文件系统类型<span class="token operator">></span>:只寻找该文件系统类型下的文件或目录;
</span><span class="code-line line-number" line="11">-gid<span class="token operator">&#x3C;</span>群组识别码<span class="token operator">></span>:查找符合指定之群组识别码的文件或目录;
</span><span class="code-line line-number" line="12">-group<span class="token operator">&#x3C;</span>群组名称<span class="token operator">></span>:查找符合指定之群组名称的文件或目录;
</span><span class="code-line line-number" line="13">-ilname<span class="token operator">&#x3C;</span>范本样式<span class="token operator">></span>:此参数的效果和指定“-lname”参数类似但忽略字符大小写的差别
</span><span class="code-line line-number" line="14">-iname<span class="token operator">&#x3C;</span>范本样式<span class="token operator">></span>:此参数的效果和指定“-name”参数类似但忽略字符大小写的差别
</span><span class="code-line line-number" line="15">-inum<span class="token operator">&#x3C;</span>inode编号<span class="token operator">></span>查找符合指定的inode编号的文件或目录
</span><span class="code-line line-number" line="16">-ipath<span class="token operator">&#x3C;</span>范本样式<span class="token operator">></span>:此参数的效果和指定“-path”参数类似但忽略字符大小写的差别
</span><span class="code-line line-number" line="17">-iregex<span class="token operator">&#x3C;</span>范本样式<span class="token operator">></span>:此参数的效果和指定“-regexe”参数类似但忽略字符大小写的差别
</span><span class="code-line line-number" line="18"><span class="token parameter variable">-iwholename</span> 模式参见<span class="token variable"><span class="token variable">`</span><span class="token parameter variable">-ipath</span><span class="token variable">`</span></span>。此选项的可移植性较<span class="token variable"><span class="token variable">`</span><span class="token parameter variable">-ipath</span><span class="token variable">`</span></span>差。
</span><span class="code-line line-number" line="19">-links<span class="token operator">&#x3C;</span>连接数目<span class="token operator">></span>:查找符合指定的硬连接数目的文件或目录;
</span><span class="code-line line-number" line="20">-lname<span class="token operator">&#x3C;</span>范本样式<span class="token operator">></span>:指定字符串作为寻找符号连接的范本样式;
</span><span class="code-line line-number" line="21">-mmin<span class="token operator">&#x3C;</span>分钟<span class="token operator">></span>:查找在指定时间曾被更改过的文件或目录,单位以分钟计算;
</span><span class="code-line line-number" line="22">-mtime<span class="token operator">&#x3C;</span><span class="token number">24</span>小时数<span class="token operator">></span>查找在指定时间曾被更改过的文件或目录单位以24小时计算
</span><span class="code-line line-number" line="23">-name<span class="token operator">&#x3C;</span>范本样式<span class="token operator">></span>:指定字符串作为寻找文件或目录的范本样式;
</span><span class="code-line line-number" line="24">-newer<span class="token operator">&#x3C;</span>参考文件或目录<span class="token operator">></span>:查找其更改时间较指定文件或目录的更改时间更接近现在的文件或目录;
</span><span class="code-line line-number" line="25">-newerXY<span class="token operator">&#x3C;</span>引用<span class="token operator">></span>:如果正在考虑的文件的时间戳 X 比文件引用的时间戳 Y 更新则成功。
</span><span class="code-line line-number" line="26">-nogroup找出不属于本地主机群组识别码的文件或目录
</span><span class="code-line line-number" line="27">-nouser找出不属于本地主机用户识别码的文件或目录
</span><span class="code-line line-number" line="28">-path<span class="token operator">&#x3C;</span>范本样式<span class="token operator">></span>:指定字符串作为寻找目录的范本样式;
</span><span class="code-line line-number" line="29">-perm<span class="token operator">&#x3C;</span>权限数值<span class="token operator">></span>:查找符合指定的权限数值的文件或目录;
</span><span class="code-line line-number" line="30">-readable匹配当前用户可读的文件
</span><span class="code-line line-number" line="31">-regex<span class="token operator">&#x3C;</span>范本样式<span class="token operator">></span>:指定字符串作为寻找文件或目录的范本样式;
</span><span class="code-line line-number" line="32"><span class="token parameter variable">-samefile</span> 名称 文件与名称指向相同的 inode。
</span><span class="code-line line-number" line="33">-size<span class="token operator">&#x3C;</span>文件大小<span class="token operator">></span>:查找符合指定的文件大小的文件;
</span><span class="code-line line-number" line="34">-type<span class="token operator">&#x3C;</span>文件类型<span class="token operator">></span>:只寻找符合指定的文件类型的文件;
</span><span class="code-line line-number" line="35">-uid<span class="token operator">&#x3C;</span>用户识别码<span class="token operator">></span>:查找符合指定的用户识别码的文件或目录;
</span><span class="code-line line-number" line="36">-used<span class="token operator">&#x3C;</span>日数<span class="token operator">></span>:查找文件或目录被更改之后在指定时间曾被存取过的文件或目录,单位以日计算;
</span><span class="code-line line-number" line="37">-user<span class="token operator">&#x3C;</span>拥有者名称<span class="token operator">></span>:查找符和指定的拥有者名称的文件或目录;
</span><span class="code-line line-number" line="38">-writable匹配当前用户可写入的文件。
</span><span class="code-line line-number" line="39">-xtype<span class="token operator">&#x3C;</span>文件类型<span class="token operator">></span>:此参数的效果和指定“-type”参数类似差别在于它针对符号连接检查。
</span><span class="code-line line-number" line="40">-context<span class="token operator">&#x3C;</span>表达式<span class="token operator">></span>:仅限 SELinux。文件的安全上下文与全局模式匹配
</span></code><div onclick="copied(this)" data-code="-amin<分钟>:查找在指定时间曾被存取过的文件或目录,单位以分钟计算;
-anewer<参考文件或目录>:查找其存取时间较指定文件或目录的存取时间更接近现在的文件或目录;
-atime<24小时数>查找在指定时间曾被存取过的文件或目录单位以24小时计算
-cmin<分钟>:查找在指定时间之时被更改过的文件或目录;
-cnewer<参考文件或目录>查找其更改时间较指定文件或目录的更改时间更接近现在的文件或目录;
-ctime<24小时数>查找在指定时间之时被更改的文件或目录单位以24小时计算
-empty寻找文件大小为0 Byte的文件或目录下没有任何子目录或文件的空目录
-executable 匹配当前用户可执行的文件和可搜索的目录。
-false将find指令的回传值皆设为False
-fstype<文件系统类型>:只寻找该文件系统类型下的文件或目录;
-gid<群组识别码>:查找符合指定之群组识别码的文件或目录;
-group<群组名称>:查找符合指定之群组名称的文件或目录;
-ilname<范本样式>:此参数的效果和指定“-lname”参数类似但忽略字符大小写的差别
-iname<范本样式>:此参数的效果和指定“-name”参数类似但忽略字符大小写的差别
-inum<inode编号>查找符合指定的inode编号的文件或目录
-ipath<范本样式>:此参数的效果和指定“-path”参数类似但忽略字符大小写的差别
-iregex<范本样式>:此参数的效果和指定“-regexe”参数类似但忽略字符大小写的差别
-iwholename 模式参见&#x60;-ipath&#x60;。此选项的可移植性较&#x60;-ipath&#x60;差。
-links<连接数目>:查找符合指定的硬连接数目的文件或目录;
-lname<范本样式>:指定字符串作为寻找符号连接的范本样式;
-mmin<分钟>:查找在指定时间曾被更改过的文件或目录,单位以分钟计算;
-mtime<24小时数>查找在指定时间曾被更改过的文件或目录单位以24小时计算
-name<范本样式>:指定字符串作为寻找文件或目录的范本样式;
-newer<参考文件或目录>:查找其更改时间较指定文件或目录的更改时间更接近现在的文件或目录;
-newerXY<引用>:如果正在考虑的文件的时间戳 X 比文件引用的时间戳 Y 更新则成功。
-nogroup找出不属于本地主机群组识别码的文件或目录
-nouser找出不属于本地主机用户识别码的文件或目录
-path<范本样式>:指定字符串作为寻找目录的范本样式;
-perm<权限数值>:查找符合指定的权限数值的文件或目录;
-readable匹配当前用户可读的文件
-regex<范本样式>:指定字符串作为寻找文件或目录的范本样式;
-samefile 名称 文件与名称指向相同的 inode。
-size<文件大小>:查找符合指定的文件大小的文件;
-type<文件类型>:只寻找符合指定的文件类型的文件;
-uid<用户识别码>:查找符合指定的用户识别码的文件或目录;
-used<日数>:查找文件或目录被更改之后在指定时间曾被存取过的文件或目录,单位以日计算;
-user<拥有者名称>:查找符和指定的拥有者名称的文件或目录;
-writable匹配当前用户可写入的文件。
-xtype<文件类型>:此参数的效果和指定“-type”参数类似差别在于它针对符号连接检查。
-context<表达式>:仅限 SELinux。文件的安全上下文与全局模式匹配
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h3 id="操作选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#操作选项"><span class="octicon octicon-link"></span></a>操作选项</h3>
<h4 id="-delete-删除文件或目录"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-delete-删除文件或目录"><span class="octicon octicon-link"></span></a>-delete 删除文件或目录。</h4>
<blockquote>
<p>警告find 命令会将命令行作为表达式进行解析,因此将<code>-delete</code>放在首位会将指定的起始点下的<strong>所有内容删除</strong>。且<code>-delete</code>操作无法删除一个目录,除非它是空的。</p>
</blockquote>
<h5 id="无参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述"><span class="octicon octicon-link"></span></a>描述</h5>
<p>如果删除成功则返回真。若删除失败,将显示错误消息,并且 find 最终退出时的状态码将为非零。</p>
<h5 id="相关选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#相关选项"><span class="octicon octicon-link"></span></a>相关选项</h5>
<ul>
<li><strong>-depth</strong>:在命令行中使用<code>-delete</code>操作会自动启用<code>-depth</code>选项。为了避免意外情况,通常最好在早期的<strong>Tests选项</strong><strong>明确使用</strong><code>-depth</code>选项。</li>
<li><strong>-prune</strong>:由于<code>-depth</code>会使<code>-prune</code>失效,因此<code>-delete</code>操作无法与<code>-prune</code>有效结合使用。通常,用户可能希望在实际删除操作前,先用带有<code>-print</code>的查找命令行进行测试,以确保在添加<code>-delete</code>进行实际删除时不会出现意外结果。</li>
<li><strong>-ignore_readdir_race</strong><code>-delete</code>与此选项一起使用时find 会忽略自父目录读取以来文件已消失的情况下<code>-delete</code>操作的错误:它不会输出错误诊断,不会将退出代码更改为非零,并且<code>-delete</code>操作的返回代码将为真。</li>
</ul>
<h4 id="-exec-执行命令"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-exec-执行命令"><span class="octicon octicon-link"></span></a>-exec 执行命令</h4>
<blockquote>
<p>⚠️警告:使用<code>-exec</code>操作存在不可避免的安全问题,应改用<code>-execdir</code>选项。</p>
</blockquote>
<h5 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>command ;</code><code>command {} +</code></p>
<h5 id="描述-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-1"><span class="octicon octicon-link"></span></a>描述</h5>
<p>如果返回状态为 0则结果为真。<strong>注意</strong>find 命令会将<strong>所有后续参数</strong>视为<code>command</code>的参数,直到遇到包含<code>;</code>的参数为止。字符串<code>{}</code>会在<code>command</code>的参数中所有出现的位置被替换为当前正在处理的文件名,而不仅仅是在它单独出现的参数中,这与某些版本的 find 不同。这两种结构可能需要使用反斜杠<code>\</code>或引号来转义,以防止被 shell 扩展。指定的命令会为每个匹配的文件运行一次。命令在起始目录中执行。</p>
<h4 id="-execdir-在包含匹配文件的子目录中执行命令"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-execdir-在包含匹配文件的子目录中执行命令"><span class="octicon octicon-link"></span></a>-execdir 在包含匹配文件的子目录中执行命令</h4>
<h5 id="参数-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-1"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>command ;</code> | <code>command {} +</code></p>
<h5 id="描述-2"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-2"><span class="octicon octicon-link"></span></a>描述</h5>
<p>类似于<code>-exec</code>,但指定的<code>command</code>会在包含匹配文件的<strong>子目录中运行</strong>而非find的起始点目录。与<code>-exec</code>一样如果从shell调用find<code>{}</code>应加引号。这是一种更安全的调用<code>command</code>方式,因为它避免了在解析匹配文件路径时出现的竞争条件。与<code>-exec</code>操作类似,<code>+</code>形式的<code>-execdir</code>会构建一个命令行来处理多个匹配文件,但任何给定的<code>command</code>调用只会列出存在于同一子目录中的文件。如果使用此选项,必须确保 PATH 环境变量未引用<code>.</code>,否则攻击者可以通过在您将运行<code>-execdir</code>的目录中留下一个适当命名的文件来运行任何命令。同样PATH 中的条目<strong>不应为空</strong><strong>非绝对目录名</strong>。如果使用<code>+</code>形式的任何调用以非零值作为退出状态返回,则 find 也会返回非零退出状态。如果 find 遇到错误,有时会导致立即退出,<strong>因此某些待处理的command可能根本不会运行</strong>。 操作结果取决于使用的是<code>+</code>还是<code>;</code>变体。<code>-execdir command {} + </code>总是返回真,而 <code>-execdir command {} ;</code>仅在命令返回 0 时返回真。</p>
<h4 id="-fls-创建文件并将结果写入文件"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-fls-创建文件并将结果写入文件"><span class="octicon octicon-link"></span></a>-fls 创建文件并将结果写入文件</h4>
<h5 id="参数-2"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-2"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>file</code></p>
<h5 id="描述-3"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-3"><span class="octicon octicon-link"></span></a>描述</h5>
<p>此选项始终返回真。<code>-fls</code>类似于<code>-ls</code><code>-fprint</code>,但<code>-fls</code>会将结果写入文件中。无论谓词是否匹配,输出文件始终会被创建。有关文件名中特殊字符处理的信息,请参阅“特殊文件名处理”部分。</p>
<h4 id="-fprint-将完整文件名打印到指定文件中"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-fprint-将完整文件名打印到指定文件中"><span class="octicon octicon-link"></span></a>-fprint 将完整文件名打印到指定文件中</h4>
<h5 id="参数-3"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-3"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>file</code></p>
<h5 id="描述-4"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-4"><span class="octicon octicon-link"></span></a>描述</h5>
<p>此选项始终返回真。若运行 find 时<code>file</code>不存在,则创建该<code>file</code>;若<code>file</code>已存在,则截断其内容。文件名<code>/dev/stdout</code><code>/dev/stderr</code>有特殊处理,分别指向标准输出和标准错误输出。即使谓词从未匹配,输出文件也会始终创建。</p>
<h4 id="-fprint0"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-fprint0"><span class="octicon octicon-link"></span></a>-fprint0</h4>
<h5 id="参数-4"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-4"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>file</code></p>
<h5 id="描述-5"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-5"><span class="octicon octicon-link"></span></a>描述</h5>
<p>此选项始终返回真。类似于<code>-print0</code>,但将输出写入文件;类似于<code>-fprint</code>。即使谓词从未匹配,输出文件也始终会被创建。</p>
<h4 id="-fprintf"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-fprintf"><span class="octicon octicon-link"></span></a>-fprintf</h4>
<h5 id="参数-5"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-5"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>file</code></p>
<h5 id="描述-6"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-6"><span class="octicon octicon-link"></span></a>描述</h5>
<p>此选项始终返回真。类似于<code>-printf</code>,但将输出写入文件;类似于<code>-fprint</code>,即使谓词从未匹配,输出文件也会始终创建。</p>
<h4 id="-ls-列出当前文件并输出到标准输出"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-ls-列出当前文件并输出到标准输出"><span class="octicon octicon-link"></span></a>-ls 列出当前文件并输出到标准输出</h4>
<h5 id="无参数-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-1"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-7"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-7"><span class="octicon octicon-link"></span></a>描述</h5>
<p>此选项始终返回真。以<code>ls -dils</code>格式列出当前文件并输出到标准输出。块计数为 1 KB 块,除非设置了环境变量 POSIXLY_CORRECT此时使用 512 字节块。</p>
<h4 id="-ok-执行命令前询问用户"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-ok-执行命令前询问用户"><span class="octicon octicon-link"></span></a>-ok 执行命令前询问用户</h4>
<h5 id="参数-6"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-6"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>command ;</code></p>
<h5 id="描述-8"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-8"><span class="octicon octicon-link"></span></a>描述</h5>
<p>类似于<code>-exec</code>,但首先会询问用户。如果用户同意,则运行该命令;否则仅返回 false。若运行该命令其标准输入将被重定向至<code>/dev/null</code>。对提示的响应会与一对正则表达式进行匹配以确定其为肯定或否定回答。若设置POSIXLY_CORRECT 环境变量,则该正则表达式从系统获取;否则,从 find 的消息翻译中获取。如果系统没有合适的定义,将使用 find 自身的定义。无论哪种情况,正则表达式本身的解释都会受到环境变量 LC_CTYPE字符类和 LC_COLLATE字符范围和等价类的影响。</p>
<h5 id="相关选项-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#相关选项-1"><span class="octicon octicon-link"></span></a>相关选项</h5>
<ul>
<li><strong>-files0-from</strong>:不能与<code>-ok</code>同时指定。</li>
</ul>
<h4 id="-okdir"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-okdir"><span class="octicon octicon-link"></span></a>-okdir</h4>
<h5 id="参数-7"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-7"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>command ;</code></p>
<h5 id="描述-9"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-9"><span class="octicon octicon-link"></span></a>描述</h5>
<p>类似于<code>-execdir</code>,但在执行前会以与<code>-ok</code>相同的方式询问用户。如果用户不同意,则直接返回 false。如果命令被执行其标准输入将从<code>/dev/null</code>重定向。</p>
<h5 id="相关选项-2"><a class="anchor" aria-hidden="true" tabindex="-1" href="#相关选项-2"><span class="octicon octicon-link"></span></a>相关选项</h5>
<ul>
<li><strong>-files0-from</strong>:不能与<code>-okdir</code>同时指定。</li>
</ul>
<h4 id="-print-打印完整文件名后跟一个换行符"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-print-打印完整文件名后跟一个换行符"><span class="octicon octicon-link"></span></a>-print 打印完整文件名,后跟一个换行符</h4>
<h5 id="无参数-2"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-2"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-10"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-10"><span class="octicon octicon-link"></span></a>描述</h5>
<p>此选项始终返回真。如果你将 find 的输出通过管道传输到另一个程序,并且你正在搜索的文件可能包含换行符,那么应该考虑使用<code>-print0</code>而不是<code>-print</code></p>
<h4 id="-print0-打印完整文件名后跟一个空字符"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-print0-打印完整文件名后跟一个空字符"><span class="octicon octicon-link"></span></a>-print0 打印完整文件名,后跟一个空字符</h4>
<h5 id="无参数-3"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-3"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-11"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-11"><span class="octicon octicon-link"></span></a>描述</h5>
<p>此选项始终返回真。包含换行符或其他类型空白字符的文件名能被正确解析,以便处理 find 输出的程序能正确理解。此选项对应于<code>xargs</code><code>-0</code>选项。</p>
<h4 id="-printf-打印格式"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-printf-打印格式"><span class="octicon octicon-link"></span></a>-printf 打印格式</h4>
<h5 id="参数-8"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-8"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>format</code></p>
<p>可用的转义字符和指令包括:</p>
<ul>
<li>\a 警报。</li>
<li>\b 退格键。</li>
<li>\c 立即停止打印并清空输出。</li>
<li>\f 换页。</li>
<li>\n 换行。</li>
<li>\r 回车符。</li>
<li>\t 水平制表符。</li>
<li>\v 垂直制表符。</li>
<li>\0 空字符。</li>
<li>\\ 一个字面的反斜杠<code>\</code></li>
<li>\NNN 字符,其 ASCII 码为 NNN八进制</li>
<li>A 一个反斜杠字符<code>\</code>后跟任何其他字符,都会被视为普通字符,因此它们都会被打印出来。</li>
<li>%% 一个字面的百分号。</li>
<li>
%a 文件的最后访问时间,格式为 C 语言 ctime(3)函数返回的样式。
.....更多内容待补充
</li>
</ul>
<h5 id="描述-12"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-12"><span class="octicon octicon-link"></span></a>描述</h5>
<p><em>暂无</em></p>
<h4 id="-prune-如果文件是目录则不进入该目录"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-prune-如果文件是目录则不进入该目录"><span class="octicon octicon-link"></span></a>-prune 如果文件是目录,则不进入该目录</h4>
<h5 id="无参数-4"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-4"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-13"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-13"><span class="octicon octicon-link"></span></a>描述</h5>
<p>此选项始终返回真。</p>
<h5 id="相关选项-3"><a class="anchor" aria-hidden="true" tabindex="-1" href="#相关选项-3"><span class="octicon octicon-link"></span></a>相关选项</h5>
<ul>
<li><strong>-depth</strong>:如果指定了<code>-depth</code>,那么<code>-prune</code>将无效。</li>
<li><strong>-delete</strong>:因为<code>-delete</code>隐含了<code>-depth</code>,所以不能有效地同时使用两者。</li>
</ul>
<h4 id="-quit-立即退出"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-quit-立即退出"><span class="octicon octicon-link"></span></a>-quit 立即退出</h4>
<h5 id="无参数-5"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-5"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-14"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-14"><span class="octicon octicon-link"></span></a>描述</h5>
<p>如果没有发生错误,则返回值为零。这与<code>-prune </code>不同,因为<code>-prune</code>仅适用于被修剪目录的内容,而<code>-quit</code>则使 find 立即停止。不会有任何子进程继续运行。在程序退出之前,任何通过<code>-exec ... +</code><code>-execdir ... +</code>构建的命令行都会被调用。执行<code>-quit</code>后,命令行中指定的文件将不再被处理。例如,<code>find /tmp/foo /tmp/bar -print -quit</code>将仅打印 <code>/tmp/foo</code><code>-quit</code>的一个常见用途是在找到所需内容后停止搜索文件系统。</p>
<h3 id="全局选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#全局选项"><span class="octicon octicon-link"></span></a>全局选项</h3>
<p>始终返回真值。全局选项对命令行中较早出现的测试也会生效。为避免混淆,全局选项应在命令行上列出<strong>起始点之后、第一个测试选项、位置选项或操作选项之前指定</strong>。若在其他位置指定全局选项find 会发出警告消息,说明这可能引起混淆。</p>
<blockquote>
<p>全局选项出现在起始点列表之后,因此与例如<code>-L</code> 这样的选项不属于同一类别。</p>
</blockquote>
<h4 id="-d--depth的同义词"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-d--depth的同义词"><span class="octicon octicon-link"></span></a>-d <code>-depth</code>的同义词</h4>
<h5 id="无参数-6"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-6"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-15"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-15"><span class="octicon octicon-link"></span></a>描述</h5>
<p>仅用于与 FreeBSD、NetBSD、MacOS X 和 OpenBSD 兼容。</p>
<h4 id="-depth-遍历级别"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-depth-遍历级别"><span class="octicon octicon-link"></span></a>-depth 遍历级别</h4>
<h5 id="参数-9"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-9"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>levels</code></p>
<h5 id="描述-16"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-16"><span class="octicon octicon-link"></span></a>描述</h5>
<p>在处理目录本身之前,先处理目录中的内容。<code>-delete</code>操作也隐含了<code>-depth</code></p>
<h4 id="-files0-from-从文件中读取起始点而非通过命令行获取"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-files0-from-从文件中读取起始点而非通过命令行获取"><span class="octicon octicon-link"></span></a>-files0-from 从文件中读取起始点,而非通过命令行获取。</h4>
<h5 id="参数-10"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-10"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>file</code></p>
<h5 id="描述-17"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-17"><span class="octicon octicon-link"></span></a>描述</h5>
<p>使用此选项可以安全地给 find 命令传递任意数量的起始点。使用此选项和在命令行中传递起始点<strong>是互斥的</strong>,因此不允许同时进行。文件参数是强制性的。文件中的起始点必须用 ASCII NUL 字符分隔。两个连续的 NUL 字符,即带有零长度文件名的起始点是不允许的,这将导致错误诊断,并随后产生非零退出码。</p>
<p>与标准调用不同在标准调用中如果没有传递路径参数find 会默认将当前目录作为起始点。起始点的处理方式与其他情况相同例如find 命令会递归进入子目录,除非另有阻止。若要仅处理起始点,可以额外传递<code>-maxdepth 0</code>参数。</p>
<p><strong>其他说明</strong>如果一个文件在输入文件中被列出多次则其是否会被多次访问未作规定。如果在查找操作期间文件被修改结果同样未作规定。最后find 退出时(无论是通过<code>-quit</code>还是其他方式),命名文件中的查找位置也未作规定。此处<strong>未作规定</strong>意味着它<strong>可能有效也可能无效</strong><strong>或者不做任何特定的事情</strong>,并且该行为可能因平台或 findutils 版本而异。</p>
<blockquote>
<p>💡可以使用<code>-files0-from</code><strong>从标准输入流中读取起始点列表</strong>,例如从管道中读取。在这种情况下,不允许使用<code>-ok</code><code>-okdir</code>操作,因为它们会干扰从标准输入读取以获取用户确认。</p>
</blockquote>
<blockquote>
<p>警告如果给定文件为空find 不会处理任何起始点,因此在解析完程序参数后会立即退出。</p>
</blockquote>
<h4 id="-help-和---help-打印-find-命令行用法的摘要并退出"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-help-和---help-打印-find-命令行用法的摘要并退出"><span class="octicon octicon-link"></span></a>-help 和 --help 打印 find 命令行用法的摘要并退出。</h4>
<h5 id="无参数-7"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-7"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-18"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-18"><span class="octicon octicon-link"></span></a>描述</h5>
<p><em>无描述</em></p>
<h4 id="-ignore_readdir_race"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-ignore_readdir_race"><span class="octicon octicon-link"></span></a>-ignore_readdir_race</h4>
<h5 id="无参数-8"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-8"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-19"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-19"><span class="octicon octicon-link"></span></a>描述</h5>
<p>通常情况下,当 find 无法对文件进行状态检查stat会发出错误消息。如果您<strong>启用此选项</strong>,并且在 find 从目录读取文件名,到尝试进行状态检查<strong>之间的时间内文件被删除</strong>,则不会发出任何错误消息。这也适用于命令行中指定的文件或目录。此选项在命令行读取时生效,这意味着您不能在文件系统的某部分启用此选项,而在另一部分禁用它(如果需要这样做,您需要发出两个 find 命令,一个启用选项,一个不启用)。此外,使用<code>-ignore_readdir_race</code>选项时如果在读取父目录后文件已消失find 命令将忽略<code>-delete</code>操作的错误:它不会输出错误诊断信息,并且<code>-delete</code>操作的返回码将为真。</p>
<h4 id="-maxdepth-最大遍历级别"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-maxdepth-最大遍历级别"><span class="octicon octicon-link"></span></a>-maxdepth 最大遍历级别</h4>
<h5 id="参数-11"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-11"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>levels</code></p>
<h5 id="描述-20"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-20"><span class="octicon octicon-link"></span></a>描述</h5>
<p>最多向下遍历 levels 级(一个非负整数)目录层级。使用<code>-maxdepth 0</code>表示<strong>仅对起始点本身</strong>应用测试和操作。</p>
<h4 id="-mindepth-最小遍历级别"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-mindepth-最小遍历级别"><span class="octicon octicon-link"></span></a>-mindepth 最小遍历级别</h4>
<h5 id="参数-12"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-12"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>levels</code></p>
<h5 id="描述-21"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-21"><span class="octicon octicon-link"></span></a>描述</h5>
<p>在小于指定级别(非负整数)的层级上不执行任何测试或操作。使用<code>-mindepth 1</code>表示处理<strong>除起始点外的所有文件</strong></p>
<h4 id="-mount-不在其他文件系统中下降目录"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-mount-不在其他文件系统中下降目录"><span class="octicon octicon-link"></span></a>-mount 不在其他文件系统中下降目录</h4>
<h5 id="无参数-9"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-9"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-22"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-22"><span class="octicon octicon-link"></span></a>描述</h5>
<p>这是<code>-xdev</code>的替代名称,用于与其他一些版本的 find 兼容。</p>
<h4 id="-noignore_readdir_race"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-noignore_readdir_race"><span class="octicon octicon-link"></span></a>-noignore_readdir_race</h4>
<h5 id="无参数-10"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-10"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-23"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-23"><span class="octicon octicon-link"></span></a>描述</h5>
<p>关闭了<code>-ignore_readdir_race</code>的效果。</p>
<h4 id="-noleaf-不进行优化"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-noleaf-不进行优化"><span class="octicon octicon-link"></span></a>-noleaf 不进行优化。</h4>
<h5 id="无参数-11"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-11"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-24"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-24"><span class="octicon octicon-link"></span></a>描述</h5>
<p>不通过假设目录包含比其硬链接数少 2 个子目录来进行优化。在搜索不遵循 Unix 目录链接惯例的文件系统时,需要此选项,例如 CD-ROM、MS-DOS 文件系统或 AFS 卷挂载点。在正常的 Unix 文件系统上,每个目录至少有 2 个硬链接:其名称及其<code>.</code>条目。此外,其子目录(如果有)各自有一个指向该目录的<code>..</code>条目。当 find 检查一个目录时,在它已经统计了比目录链接数少 2 个子目录之后,它知道该目录中的其余条目是非目录(目录树中的“叶”文件)。如果只需要检查文件的名称,则无需对其进行状态检查;这可以显著提高搜索速度。</p>
<h4 id="-version-和---version-打印-find-的版本号并退出"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-version-和---version-打印-find-的版本号并退出"><span class="octicon octicon-link"></span></a>-version 和 --version 打印 find 的版本号并退出。</h4>
<h5 id="无参数-12"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-12"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-25"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-25"><span class="octicon octicon-link"></span></a>描述</h5>
<p><em>无描述</em></p>
<h4 id="-xdev-不进入其他文件系统的目录"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-xdev-不进入其他文件系统的目录"><span class="octicon octicon-link"></span></a>-xdev 不进入其他文件系统的目录。</h4>
<h5 id="无参数-13"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-13"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-26"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-26"><span class="octicon octicon-link"></span></a>描述</h5>
<p><em>无描述</em></p>
<h3 id="位置选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#位置选项"><span class="octicon octicon-link"></span></a>位置选项</h3>
<p>始终返回真值。它们仅影响命令行中后续的测试。</p>
<h4 id="-daystart-从今天开始"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-daystart-从今天开始"><span class="octicon octicon-link"></span></a>-daystart 从今天开始</h4>
<blockquote>
<p>用于 <code>-amin</code><code>-atime</code><code>-cmin</code><code>-ctime</code><code>-mmin</code><code>-mtime</code></p>
</blockquote>
<h5 id="无参数-14"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-14"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-27"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-27"><span class="octicon octicon-link"></span></a>描述</h5>
<p>从今天开始而非从 24 小时前开始。此选项仅影响命令行中后续出现的测试。</p>
<h4 id="-follow-解引用符号链接"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-follow-解引用符号链接"><span class="octicon octicon-link"></span></a><del>-follow</del> 解引用符号链接。</h4>
<h5 id="无参数-15"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-15"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-28"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-28"><span class="octicon octicon-link"></span></a>描述</h5>
<p><strong>已弃用,请改用<code>-L</code>选项</strong>。隐含<code>-noleaf</code><code>-follow</code>选项仅影响命令行中出现在其后的那些测试。除非已指定<code>-H</code><code>-L</code>选项,否则<code>-follow</code>选项的位置会改变<code>-newer</code>谓词的行为;作为<code>-newer</code>参数列出的任何文件,如果它们是符号链接,则会被解引用。同样的情况适用于<code>-newerXY</code><code>-anewer</code><code>-cnewer</code>。类似地,<code>-type </code>谓词将始终匹配符号链接所指向的文件类型,而非链接本身。使用<code>-follow</code>会导致 <code>-lname</code><code>-ilname</code>谓词始终返回 false。</p>
<h4 id="-regextype-更改正则表达式语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-regextype-更改正则表达式语法"><span class="octicon octicon-link"></span></a>-regextype 更改正则表达式语法</h4>
<h5 id="参数-13"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-13"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>type</code></p>
<h5 id="描述-29"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-29"><span class="octicon octicon-link"></span></a>描述</h5>
<p>更改<code>-regex</code><code>-iregex</code>测试在命令行后续部分所理解的正则表达式语法。要查看已知的正则表达式类型,请使用<code>-regextype help</code>。Texinfo 文档解释了各种正则表达式类型的含义及其差异。如果您不使用此选项find 的行为如同已指定正则表达式类型为<code>emacs</code></p>
<h4 id="-warn-和--nowarn-开启或关闭警告消息"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-warn-和--nowarn-开启或关闭警告消息"><span class="octicon octicon-link"></span></a>-warn 和 -nowarn 开启或关闭警告消息。</h4>
<h5 id="无参数-16"><a class="anchor" aria-hidden="true" tabindex="-1" href="#无参数-16"><span class="octicon octicon-link"></span></a><em>无参数</em></h5>
<h5 id="描述-30"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-30"><span class="octicon octicon-link"></span></a>描述</h5>
<p>这些警告仅适用于命令行使用,不适用于 find 在搜索目录时可能遇到的情况。默认行为是:如果标准输入是<code>tty</code>,则对应<code>-warn</code>;否则对应<code>-nowarn</code>。如果产生与命令行使用相关的警告消息find 的退出状态不受影响。如果设置了 POSIXLY_CORRECT 环境变量,并且也使用了<code>-warn</code>,则未指定哪些(如果有)警告会被激活。</p>
<h3 id="运算符选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#运算符选项"><span class="octicon octicon-link"></span></a>运算符选项</h3>
<p>运算符按优先级递减顺序列出:</p>
<ul>
<li><code>(expr)</code> 强制优先级。由于括号对 shell 有特殊含义,通常需要对它们进行引用。许多示例为此使用了反斜杠:<code>\(...\)</code> 而非 <code>(...)</code></li>
<li><code>! expr</code> 若表达式为假则结果为真(取反)。此字符通常也需要防止被 shell 解释。</li>
</ul>
<blockquote>
<p>💡提示:当<code>-a</code>隐式指定(例如两个测试之间没有显式运算符)或显式指定时,其优先级高于<code>-o</code>。例如,<code>find . -name foo -o -name bar -print</code>永远不会打印<code>foo</code></p>
</blockquote>
<h4 id="-not"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-not"><span class="octicon octicon-link"></span></a>-not</h4>
<h5 id="参数-14"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-14"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>expr</code></p>
<h5 id="描述-31"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-31"><span class="octicon octicon-link"></span></a>描述</h5>
<p>等同于<code>! expr</code>,但不符合 POSIX 标准。</p>
<h4 id="-a"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-a"><span class="octicon octicon-link"></span></a>-a</h4>
<h5 id="参数-15"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-15"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>expr1</code> -a <code>expr2</code></p>
<h5 id="描述-32"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-32"><span class="octicon octicon-link"></span></a>描述</h5>
<p>两个连续的表达式被视为隐含地用<code>-a</code>连接;如果<code>expr1</code>为假,则不评估<code>expr2</code>。等同于<code>expr1 expr2</code></p>
<h4 id="-and"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-and"><span class="octicon octicon-link"></span></a>-and</h4>
<h5 id="参数-16"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-16"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>expr1</code> -and <code>expr2</code></p>
<h5 id="描述-33"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-33"><span class="octicon octicon-link"></span></a>描述</h5>
<p><code>-a</code>相同。但不符合 POSIX 标准。</p>
<h4 id="-o"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-o"><span class="octicon octicon-link"></span></a>-o</h4>
<h5 id="参数-17"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-17"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>expr1</code> -o <code>expr2</code></p>
<h5 id="描述-34"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-34"><span class="octicon octicon-link"></span></a>描述</h5>
<p><code>expr1</code><code>expr2</code>始终都会被评估。<code>expr1</code>的值会被丢弃;列表的值即为<code>expr2</code>的值。逗号运算符(<code>,</code>)在搜索多种不同类型的事物时非常有用,但只会遍历文件系统层次结构一次。<code>-fprintf</code>动作可用于将各种匹配项列出到多个不同的输出文件中。若<code>expr1</code>为真,则不评估<code>expr2</code></p>
<h4 id="-or"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-or"><span class="octicon octicon-link"></span></a>-or</h4>
<h5 id="参数-18"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数-18"><span class="octicon octicon-link"></span></a>参数</h5>
<p><code>expr1</code> -or <code>expr2</code></p>
<h5 id="描述-35"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述-35"><span class="octicon octicon-link"></span></a>描述</h5>
<p><code>-o</code>相同。但不符合 POSIX 标准。</p>
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
<p>当前目录搜索所有文件,且文件内容包含 “140.206.111.111”</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-name</span> <span class="token string">"*"</span> <span class="token operator">|</span> <span class="token function">xargs</span> <span class="token function">grep</span> <span class="token string">"140.206.111.111"</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -name &#x22;*&#x22; | xargs grep &#x22;140.206.111.111&#x22;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="根据文件或者正则表达式进行匹配"><a class="anchor" aria-hidden="true" tabindex="-1" href="#根据文件或者正则表达式进行匹配"><span class="octicon octicon-link"></span></a>根据文件或者正则表达式进行匹配</h4>
<p>列出当前目录及子目录下所有文件和文件夹</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span>
</span></code><div onclick="copied(this)" data-code="find .
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p><code>/home</code>目录下查找以.txt结尾的文件名</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> /home <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span>
</span></code><div onclick="copied(this)" data-code="find /home -name &#x22;*.txt&#x22;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>同上,但忽略大小写</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> /home <span class="token parameter variable">-iname</span> <span class="token string">"*.txt"</span>
</span></code><div onclick="copied(this)" data-code="find /home -iname &#x22;*.txt&#x22;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>当前目录及子目录下查找所有以.txt和.pdf结尾的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token punctuation">\</span><span class="token punctuation">(</span> <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-name</span> <span class="token string">"*.pdf"</span> <span class="token punctuation">\</span><span class="token punctuation">)</span>
</span><span class="code-line line-number" line="2">
</span><span class="code-line line-number" line="3">
</span><span class="code-line line-number" line="4">
</span><span class="code-line line-number" line="5"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-name</span> <span class="token string">"*.pdf"</span>
</span></code><div onclick="copied(this)" data-code="find . \( -name &#x22;*.txt&#x22; -o -name &#x22;*.pdf&#x22; \)
find . -name &#x22;*.txt&#x22; -o -name &#x22;*.pdf&#x22;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>匹配文件路径或者文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> /usr/ <span class="token parameter variable">-path</span> <span class="token string">"*local*"</span>
</span></code><div onclick="copied(this)" data-code="find /usr/ -path &#x22;*local*&#x22;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>基于正则表达式匹配文件路径</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-regex</span> <span class="token string">".*\(\.txt\|\.pdf\)$"</span>
</span></code><div onclick="copied(this)" data-code="find . -regex &#x22;.*\(\.txt\|\.pdf\)$&#x22;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>同上,但忽略大小写</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-iregex</span> <span class="token string">".*\(\.txt\|\.pdf\)$"</span>
</span></code><div onclick="copied(this)" data-code="find . -iregex &#x22;.*\(\.txt\|\.pdf\)$&#x22;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="否定参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#否定参数"><span class="octicon octicon-link"></span></a>否定参数</h4>
<p>找出/home下不是以.txt结尾的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> /home <span class="token operator">!</span> <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span>
</span></code><div onclick="copied(this)" data-code="find /home ! -name &#x22;*.txt&#x22;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="根据文件类型进行搜索"><a class="anchor" aria-hidden="true" tabindex="-1" href="#根据文件类型进行搜索"><span class="octicon octicon-link"></span></a>根据文件类型进行搜索</h4>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> 类型参数
</span></code><div onclick="copied(this)" data-code="find . -type 类型参数
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>类型参数列表:</p>
<ul>
<li><strong>f</strong> 普通文件</li>
<li><strong>l</strong> 符号连接</li>
<li><strong>d</strong> 目录</li>
<li><strong>c</strong> 字符设备</li>
<li><strong>b</strong> 块设备</li>
<li><strong>s</strong> 套接字</li>
<li><strong>p</strong> Fifo</li>
</ul>
<h4 id="基于目录深度搜索"><a class="anchor" aria-hidden="true" tabindex="-1" href="#基于目录深度搜索"><span class="octicon octicon-link"></span></a>基于目录深度搜索</h4>
<p>向下最大深度限制为3</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-maxdepth</span> <span class="token number">3</span> <span class="token parameter variable">-type</span> f
</span></code><div onclick="copied(this)" data-code="find . -maxdepth 3 -type f
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>搜索出深度距离当前目录至少2个子目录的所有文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-mindepth</span> <span class="token number">2</span> <span class="token parameter variable">-type</span> f
</span></code><div onclick="copied(this)" data-code="find . -mindepth 2 -type f
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="根据文件时间戳进行搜索"><a class="anchor" aria-hidden="true" tabindex="-1" href="#根据文件时间戳进行搜索"><span class="octicon octicon-link"></span></a>根据文件时间戳进行搜索</h4>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f 时间戳
</span></code><div onclick="copied(this)" data-code="find . -type f 时间戳
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>UNIX/Linux文件系统每个文件都有三种时间戳</p>
<ul>
<li><strong>访问时间</strong> -atime/天,-amin/分钟):用户最近一次访问时间。</li>
<li><strong>修改时间</strong> -mtime/天,-mmin/分钟):文件最后一次修改时间。</li>
<li><strong>变化时间</strong> -ctime/天,-cmin/分钟):文件数据元(例如权限等)最后一次修改时间。</li>
</ul>
<p>搜索最近七天内被访问过的所有文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-atime</span> <span class="token parameter variable">-7</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -atime -7
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>搜索恰好在七天前被访问过的所有文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-atime</span> <span class="token number">7</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -atime 7
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>搜索超过七天内被访问过的所有文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-atime</span> +7
</span></code><div onclick="copied(this)" data-code="find . -type f -atime +7
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>搜索访问时间超过10分钟的所有文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-amin</span> +10
</span></code><div onclick="copied(this)" data-code="find . -type f -amin +10
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>找出比file.log修改时间更长的所有文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-newer</span> file.log
</span></code><div onclick="copied(this)" data-code="find . -type f -newer file.log
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="根据文件大小进行匹配"><a class="anchor" aria-hidden="true" tabindex="-1" href="#根据文件大小进行匹配"><span class="octicon octicon-link"></span></a>根据文件大小进行匹配</h4>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-size</span> 文件大小单元
</span></code><div onclick="copied(this)" data-code="find . -type f -size 文件大小单元
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>文件大小单元:</p>
<ul>
<li><strong>b</strong> —— 块512字节</li>
<li><strong>c</strong> —— 字节</li>
<li><strong>w</strong> —— 字2字节</li>
<li><strong>k</strong> —— 千字节</li>
<li><strong>M</strong> —— 兆字节</li>
<li><strong>G</strong> —— 吉字节</li>
</ul>
<p>搜索大于10KB的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-size</span> +10k
</span></code><div onclick="copied(this)" data-code="find . -type f -size +10k
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>搜索小于10KB的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-size</span> <span class="token parameter variable">-10k</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -size -10k
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>搜索等于10KB的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-size</span> 10k
</span></code><div onclick="copied(this)" data-code="find . -type f -size 10k
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="删除匹配文件"><a class="anchor" aria-hidden="true" tabindex="-1" href="#删除匹配文件"><span class="octicon octicon-link"></span></a>删除匹配文件</h4>
<p>删除当前目录下所有.txt文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span> <span class="token parameter variable">-delete</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -name &#x22;*.txt&#x22; -delete
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="根据文件权限所有权进行匹配"><a class="anchor" aria-hidden="true" tabindex="-1" href="#根据文件权限所有权进行匹配"><span class="octicon octicon-link"></span></a>根据文件权限/所有权进行匹配</h4>
<p>当前目录下搜索出权限为777的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-perm</span> <span class="token number">777</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -perm 777
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>找出当前目录下权限不是644的php文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-name</span> <span class="token string">"*.php"</span> <span class="token operator">!</span> <span class="token parameter variable">-perm</span> <span class="token number">644</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -name &#x22;*.php&#x22; ! -perm 644
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>找出当前目录用户tom拥有的所有文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-user</span> tom
</span></code><div onclick="copied(this)" data-code="find . -type f -user tom
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>找出当前目录用户组sunk拥有的所有文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-group</span> sunk
</span></code><div onclick="copied(this)" data-code="find . -type f -group sunk
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="借助-exec选项与其他命令结合使用"><a class="anchor" aria-hidden="true" tabindex="-1" href="#借助-exec选项与其他命令结合使用"><span class="octicon octicon-link"></span></a>借助<code>-exec</code>选项与其他命令结合使用</h4>
<p>找出当前目录下所有root的文件并把所有权更改为用户tom</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> .-type f <span class="token parameter variable">-user</span> root <span class="token parameter variable">-exec</span> <span class="token function">chown</span> tom <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">\</span><span class="token punctuation">;</span>
</span></code><div onclick="copied(this)" data-code="find .-type f -user root -exec chown tom {} \;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>上例中, <strong>{}</strong> 用于与 <strong>-exec</strong> 选项结合使用来匹配所有文件,然后会被替换为相应的文件名。</p>
<p>找出自己家目录下所有的.txt文件并删除</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token environment constant">$HOME</span>/. <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span> <span class="token parameter variable">-ok</span> <span class="token function">rm</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">\</span><span class="token punctuation">;</span>
</span></code><div onclick="copied(this)" data-code="find $HOME/. -name &#x22;*.txt&#x22; -ok rm {} \;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>上例中, <strong>-ok</strong><strong>-exec</strong> 行为一样,不过它会给出提示,是否执行相应的操作。</p>
<p>查找当前目录下所有.txt文件并把他们拼接起来写入到all.txt文件中</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span> <span class="token parameter variable">-exec</span> <span class="token function">cat</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">\</span><span class="token punctuation">;</span><span class="token operator">></span> /all.txt
</span></code><div onclick="copied(this)" data-code="find . -type f -name &#x22;*.txt&#x22; -exec cat {} \;> /all.txt
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>将30天前的.log文件移动到old目录中</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-mtime</span> +30 <span class="token parameter variable">-name</span> <span class="token string">"*.log"</span> <span class="token parameter variable">-exec</span> <span class="token function">cp</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> old <span class="token punctuation">\</span><span class="token punctuation">;</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -mtime +30 -name &#x22;*.log&#x22; -exec cp {} old \;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>找出当前目录下所有.txt文件并以“File:文件名”的形式打印出来</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span> <span class="token parameter variable">-exec</span> <span class="token builtin class-name">printf</span> <span class="token string">"File: %s<span class="token entity" title="\n">\n</span>"</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">\</span><span class="token punctuation">;</span>
</span></code><div onclick="copied(this)" data-code="find . -type f -name &#x22;*.txt&#x22; -exec printf &#x22;File: %s\n&#x22; {} \;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>因为单行命令中-exec参数中无法使用多个命令以下方法可以实现在-exec之后接受多条命令</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token parameter variable">-exec</span> ./text.sh <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">\</span><span class="token punctuation">;</span>
</span></code><div onclick="copied(this)" data-code="-exec ./text.sh {} \;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="搜索但跳过指定的目录"><a class="anchor" aria-hidden="true" tabindex="-1" href="#搜索但跳过指定的目录"><span class="octicon octicon-link"></span></a>搜索但跳过指定的目录</h4>
<p>查找当前目录或者子目录下所有.txt文件但是跳过子目录sk</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-path</span> <span class="token string">"./sk"</span> <span class="token parameter variable">-prune</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span> <span class="token parameter variable">-print</span>
</span></code><div onclick="copied(this)" data-code="find . -path &#x22;./sk&#x22; -prune -o -name &#x22;*.txt&#x22; -print
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<blockquote>
<p>⚠️ ./sk 不能写成 ./sk/ ,否则没有作用。</p>
</blockquote>
<p>忽略两个目录</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token punctuation">\</span><span class="token punctuation">(</span> <span class="token parameter variable">-path</span> ./sk <span class="token parameter variable">-o</span> <span class="token parameter variable">-path</span> ./st <span class="token punctuation">\</span><span class="token punctuation">)</span> <span class="token parameter variable">-prune</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-name</span> <span class="token string">"*.txt"</span> <span class="token parameter variable">-print</span>
</span></code><div onclick="copied(this)" data-code="find . \( -path ./sk -o -path ./st \) -prune -o -name &#x22;*.txt&#x22; -print
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<blockquote>
<p>⚠️ 如果写相对路径必须加上<code>./</code></p>
</blockquote>
<h4 id="find其他技巧收集"><a class="anchor" aria-hidden="true" tabindex="-1" href="#find其他技巧收集"><span class="octicon octicon-link"></span></a>find其他技巧收集</h4>
<p>要列出所有长度为零的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-empty</span>
</span></code><div onclick="copied(this)" data-code="find . -empty
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<h4 id="其它实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#其它实例"><span class="octicon octicon-link"></span></a>其它实例</h4>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> ~ <span class="token parameter variable">-name</span> <span class="token string">'*jpg'</span> <span class="token comment"># 主目录中找到所有的 jpg 文件。 -name 参数允许你将结果限制为与给定模式匹配的文件。</span>
</span><span class="code-line line-number" line="2"><span class="token function">find</span> ~ <span class="token parameter variable">-iname</span> <span class="token string">'*jpg'</span> <span class="token comment"># -iname 就像 -name但是不区分大小写</span>
</span><span class="code-line line-number" line="3"><span class="token function">find</span> ~ <span class="token punctuation">(</span> <span class="token parameter variable">-iname</span> <span class="token string">'jpeg'</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-iname</span> <span class="token string">'jpg'</span> <span class="token punctuation">)</span> <span class="token comment"># 一些图片可能是 .jpeg 扩展名。幸运的是,我们可以将模式用“或”(表示为 -o来组合。</span>
</span><span class="code-line line-number" line="4"><span class="token function">find</span> ~ <span class="token punctuation">\</span><span class="token punctuation">(</span> <span class="token parameter variable">-iname</span> <span class="token string">'*jpeg'</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-iname</span> <span class="token string">'*jpg'</span> <span class="token punctuation">\</span><span class="token punctuation">)</span> <span class="token parameter variable">-type</span> f <span class="token comment"># 如果你有一些以 jpg 结尾的目录呢? (为什么你要命名一个 bucketofjpg 而不是 pictures 的目录就超出了本文的范围。)我们使用 -type 参数修改我们的命令来查找文件。</span>
</span><span class="code-line line-number" line="5"><span class="token function">find</span> ~ <span class="token punctuation">\</span><span class="token punctuation">(</span> <span class="token parameter variable">-iname</span> <span class="token string">'*jpeg'</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-iname</span> <span class="token string">'*jpg'</span> <span class="token punctuation">\</span><span class="token punctuation">)</span> <span class="token parameter variable">-type</span> d <span class="token comment"># 也许你想找到那些命名奇怪的目录,以便稍后重命名它们</span>
</span></code><div onclick="copied(this)" data-code="find ~ -name &#x27;*jpg&#x27; # 主目录中找到所有的 jpg 文件。 -name 参数允许你将结果限制为与给定模式匹配的文件。
find ~ -iname &#x27;*jpg&#x27; # -iname 就像 -name但是不区分大小写
find ~ ( -iname &#x27;jpeg&#x27; -o -iname &#x27;jpg&#x27; ) # 一些图片可能是 .jpeg 扩展名。幸运的是,我们可以将模式用“或”(表示为 -o来组合。
find ~ \( -iname &#x27;*jpeg&#x27; -o -iname &#x27;*jpg&#x27; \) -type f # 如果你有一些以 jpg 结尾的目录呢? (为什么你要命名一个 bucketofjpg 而不是 pictures 的目录就超出了本文的范围。)我们使用 -type 参数修改我们的命令来查找文件。
find ~ \( -iname &#x27;*jpeg&#x27; -o -iname &#x27;*jpg&#x27; \) -type d # 也许你想找到那些命名奇怪的目录,以便稍后重命名它们
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>最近拍了很多照片,所以让我们把它缩小到上周更改的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> ~ <span class="token punctuation">\</span><span class="token punctuation">(</span> <span class="token parameter variable">-iname</span> <span class="token string">'*jpeg'</span> <span class="token parameter variable">-o</span> <span class="token parameter variable">-iname</span> <span class="token string">'*jpg'</span> <span class="token punctuation">\</span><span class="token punctuation">)</span> <span class="token parameter variable">-type</span> f <span class="token parameter variable">-mtime</span> <span class="token parameter variable">-7</span>
</span></code><div onclick="copied(this)" data-code="find ~ \( -iname &#x27;*jpeg&#x27; -o -iname &#x27;*jpg&#x27; \) -type f -mtime -7
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>你可以根据文件状态更改时间 ctime、修改时间 mtime 或访问时间 atime 来执行时间过滤。 这些是在几天内,所以如果你想要更细粒度的控制,你可以表示为在几分钟内(分别是 cmin、mmin 和 amin。 除非你确切地知道你想要的时间,否则你可能会在 + (大于)或 - (小于)的后面加上数字。</p>
<p>但也许你不关心你的照片。也许你的磁盘空间不够用,所以你想在 log 目录下找到所有巨大的(让我们定义为“大于 1GB”文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> /var/log <span class="token parameter variable">-size</span> +1G
</span></code><div onclick="copied(this)" data-code="find /var/log -size +1G
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>或者,也许你想在 /data 中找到 bcotton 拥有的所有文件:</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> /data <span class="token parameter variable">-owner</span> bcotton
</span></code><div onclick="copied(this)" data-code="find /data -owner bcotton
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>你还可以根据权限查找文件。也许你想在你的主目录中找到对所有人可读的文件,以确保你不会过度分享。</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> ~ <span class="token parameter variable">-perm</span> <span class="token parameter variable">-o</span><span class="token operator">=</span>r
</span></code><div onclick="copied(this)" data-code="find ~ -perm -o=r
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>删除 mac 下自动生成的文件</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> ./ <span class="token parameter variable">-name</span> <span class="token string">'__MACOSX'</span> <span class="token parameter variable">-depth</span> <span class="token parameter variable">-exec</span> <span class="token function">rm</span> <span class="token parameter variable">-rf</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">\</span><span class="token punctuation">;</span>
</span></code><div onclick="copied(this)" data-code="find ./ -name &#x27;__MACOSX&#x27; -depth -exec rm -rf {} \;
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<p>统计代码行数</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">find</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-name</span> <span class="token string">"*.java"</span><span class="token operator">|</span><span class="token function">xargs</span> <span class="token function">cat</span><span class="token operator">|</span><span class="token function">grep</span> <span class="token parameter variable">-v</span> ^$<span class="token operator">|</span><span class="token function">wc</span> <span class="token parameter variable">-l</span> <span class="token comment"># 代码行数统计, 排除空行</span>
</span></code><div onclick="copied(this)" data-code="find . -name &#x22;*.java&#x22;|xargs cat|grep -v ^$|wc -l # 代码行数统计, 排除空行
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
<style>markdown-style pre .copied {
display: flex;
position: absolute;
cursor: pointer;
color: #a5afbb;
top: 6px;
right: 6px;
border-radius: 5px;
background: #82828226;
padding: 6px;
font-size: 12px;
transition: all .3s;
}
markdown-style pre .copied:not(.active) {
visibility: hidden;
}
markdown-style pre:hover .copied {
visibility: visible;
}
markdown-style pre:hover .copied:hover {
background: #4caf50;
color: #fff;
}
markdown-style pre:hover .copied:active,
markdown-style pre .copied.active {
background: #2e9b33;
color: #fff;
}
markdown-style pre .copied .octicon-copy {
display: block;
}
markdown-style pre .copied .octicon-check {
display: none;
}
markdown-style pre .active .octicon-copy {
display: none;
}
markdown-style pre .active .octicon-check {
display: block;
}</style><script>/*! @uiw/copy-to-clipboard v1.0.12 | MIT (c) 2021 Kenny Wang | https://github.com/uiwjs/copy-to-clipboard.git */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).copyTextToClipboard=t()}(this,(function(){"use strict";return function(e,t){const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style={position:"absolute",left:"-9999px"},document.body.appendChild(o);const n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);o.select();let c=!1;try{c=!!document.execCommand("copy")}catch(e){c=!1}document.body.removeChild(o),n&&document.getSelection&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n)),t&&t(c)}}));
function copied(target, str) {
target.classList.add('active');
copyTextToClipboard(target.dataset.code, function() {
setTimeout(() => {
target.classList.remove('active');
}, 2000);
});
}</script></markdown-style>
</div>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->
<div class="footer ">
<a target="_blank" href="https://github.com/jaywcjlove/linux-command/new/master/command">添加命令</a> |
<a href="../hot.html">命令列表</a> |
<a href="https://github.com/jaywcjlove/oscnews" target="_blank">Chrome 插件</a> |
<a href="https://github.com/jaywcjlove/linux-command/releases" target="_blank">Alfred</a> |
<a href="https://jaywcjlove.github.io/linux-command/linux-command.docset.zip" target="_blank">Dash</a> |
<a href="https://github.com/roachsinai/krunner-linuxcommands" target="_blank">Krunner</a> |
<a href="http://jaywcjlove.gitee.io/linux-command/" target="_blank">开源中国Web版</a>
<br />
<a href="https://jaywcjlove.github.io/#/sponsor" target="_blank">打赏捐赠</a> |
<a href="https://github.com/jaywcjlove/linux-command" target="_blank">Github</a> |
<a href="https://jaywcjlove.github.io/linux-command/" target="_blank">短地址https://git.io/linux</a>
<div>
收藏本站请使用 Ctrl+D 或者Command+d
<br />
共搜集到
<span id="commands_info">
611
</span> 个Linux命令超过 <a href="../contributors.html">50+</a> 贡献者
</div>
<div>
<a target="_blank" href="../contributors.html#镜像网站">镜像网站</a>列表,
<a href="https://github.com/jaywcjlove/linux-command/issues/649" target="_blank">推荐</a>自己的镜像网站
</div>
</div>
<script type="text/javascript" src="../js/dt.js?v=1751947536256"></script>
<script type="text/javascript" src="../js/index.js?v=1751947536256"></script>
</body>
</html>