{"id":16566,"date":"2024-11-18T14:13:37","date_gmt":"2024-11-18T06:13:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/16566\/"},"modified":"2024-11-18T14:13:37","modified_gmt":"2024-11-18T06:13:37","slug":"linux%e5%91%bd%e4%bb%a4%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/16566\/","title":{"rendered":"Linux\u547d\u4ee4\u5927\u5168"},"content":{"rendered":"<p> <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/28e682cc2227855e2102ba4b1407d8ed-0.png\" class=\"aligncenter\" title=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe\" alt=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe\" \/><\/p>\n<blockquote style=\"padding-top: 1px;padding-right: 10px;padding-bottom: 1px;border-left-width: 5px;font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\n<p style=\"margin: 0.5em 5px !important\"><strong>\u6ce8\u610f\uff1a\u4e3a\u4e86\u65b9\u4fbf\u4ee3\u7801\u9605\u8bfb\uff0c\u6587\u7ae0\u4ee3\u7801\u5757\u91cc\u628a\u8868\u793a\u7ba1\u7406\u5458\u6a21\u5f0f\u7684#\u90fd\u53bb\u6389\u4e86\u3002\u8fd9\u4e0d\u662f\u9519\u8bef\u3002\u4e0d\u8981\u641e\u9519\uff01\uff01<\/strong><\/p>\n<\/blockquote>\n<h1>\u4e00\u3001\u57fa\u672c\u64cd\u4f5c\u547d\u4ee4<\/h1>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u9996\u5148\u5148\u6765\u51e0\u4e2a\u70ed\u952e\uff0c\u975e\u5e38\u65b9\u4fbf\uff0c\u4e00\u5b9a\u8981\u8bb0\u4f4f<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>Tab\u6309\u952e\u2014\u547d\u4ee4\u8865\u9f50\u529f\u80fd<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>Ctrl+c\u6309\u952e\u2014\u505c\u6389\u6b63\u5728\u8fd0\u884c\u7684\u7a0b\u5e8f<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>Ctrl+d\u6309\u952e\u2014\u76f8\u5f53\u4e8eexit\uff0c\u9000\u51fa<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>Ctrl+l\u6309\u952e\u2014\u6e05\u5c4f<\/strong><\/p>\n<h2>1.1 \u5173\u673a\u548c\u91cd\u542f<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>1.\u5173\u673a\u547d\u4ee4\uff1ashutdown<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5728\u9886\u57df\u5185\u5927\u591a\u7528\u5728\u670d\u52a1\u5668\u4e0a\uff0c\u5f88\u5c11\u9047\u5230\u5173\u673a\u7684\u64cd\u4f5c\u3002\u6bd5\u7adf\u670d\u52a1\u5668\u4e0a\u8dd1\u4e00\u4e2a\u670d\u52a1\u662f\u6c38\u65e0\u6b62\u5883\u7684\uff0c\u9664\u975e\u7279\u6b8a\u60c5\u51b5\u4e0b\uff0c\u4e0d\u5f97\u5df2\u624d\u4f1a\u5173\u673a\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6b63\u786e\u7684\u5173\u673a\u6d41\u7a0b\u4e3a\uff1a<strong>sync &gt; shutdown &gt; reboot &gt; halt<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f8b\u5982\u4f60\u53ef\u4ee5\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5173\u673a\uff1a<\/p>\n<pre>sync&nbsp;\u5c06\u6570\u636e\u7531\u5185\u5b58\u540c\u6b65\u5230\u786c\u76d8\u4e2d\u3002shutdown&nbsp;\u5173\u673a\u6307\u4ee4\uff0c\u4f60\u53ef\u4ee5man&nbsp;shutdown&nbsp;\u6765\u770b\u4e00\u4e0b\u5e2e\u52a9\u6587\u6863\u3002\u4f8b\u5982\u4f60\u53ef\u4ee5\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5173\u673a\uff1ashutdown&nbsp;\u2013h&nbsp;10&nbsp;\u2018This&nbsp;server&nbsp;will&nbsp;shutdown&nbsp;after&nbsp;10&nbsp;mins\u2019&nbsp;\u8fd9\u4e2a\u547d\u4ee4\u544a\u8bc9\u5927\u5bb6\uff0c\u8ba1\u7b97\u673a\u5c06\u572810\u5206\u949f\u540e\u5173\u673a\uff0c\u5e76\u4e14\u4f1a\u663e\u793a\u5728\u767b\u9646\u7528\u6237\u7684\u5f53\u524d\u5c4f\u5e55\u4e2d\u3002shutdown&nbsp;\u2013h&nbsp;now&nbsp;\u7acb\u9a6c\u5173\u673ashutdown&nbsp;\u2013h&nbsp;20:25&nbsp;\u7cfb\u7edf\u4f1a\u5728\u4eca\u592920:25\u5173\u673ashutdown&nbsp;\u2013h&nbsp;+10&nbsp;\u5341\u5206\u949f\u540e\u5173\u673ashutdown&nbsp;\u2013r&nbsp;now&nbsp;\u7cfb\u7edf\u7acb\u9a6c\u91cd\u542fshutdown&nbsp;\u2013r&nbsp;+10&nbsp;\u7cfb\u7edf\u5341\u5206\u949f\u540e\u91cd\u542freboot&nbsp;\u5c31\u662f\u91cd\u542f\uff0c\u7b49\u540c\u4e8e&nbsp;shutdown&nbsp;\u2013r&nbsp;nowhalt&nbsp;\u5173\u95ed\u7cfb\u7edf\uff0c\u7b49\u540c\u4e8eshutdown&nbsp;\u2013h&nbsp;now&nbsp;\u548c&nbsp;poweroff<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6837\u4f8b\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><\/p>\n<p style=\"margin-bottom: 0em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/98a34095df5ea7e738f082d20478bc35-1.png\" class=\"aligncenter\" title=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe1\" alt=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe1\" \/><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u53d6\u6d88\u5b9a\u65f6\u5173\u673a\u547d\u4ee4\uff1ashutdown -c<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6700\u540e\u603b\u7ed3\u4e00\u4e0b\uff0c\u4e0d\u7ba1\u662f\u91cd\u542f\u7cfb\u7edf\u8fd8\u662f\u5173\u95ed\u7cfb\u7edf\uff0c\u9996\u5148\u8981\u8fd0\u884c<span>&nbsp;<\/span><strong>sync<\/strong><span>&nbsp;<\/span>\u547d\u4ee4\uff0c\u628a\u5185\u5b58\u4e2d\u7684\u6570\u636e\u5199\u5230\u78c1\u76d8\u4e2d\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5173\u673a\u7684\u547d\u4ee4\u6709<span>&nbsp;<\/span><strong>shutdown \u2013h now halt poweroff<\/strong><span>&nbsp;<\/span>\u548c<span>&nbsp;<\/span><strong>init 0<\/strong><span>&nbsp;<\/span>, \u91cd\u542f\u7cfb\u7edf\u7684\u547d\u4ee4\u6709<span>&nbsp;<\/span><strong>shutdown \u2013r now reboot init 6<\/strong>\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>2.\u91cd\u542f\u547d\u4ee4\uff1areboot<\/strong><\/p>\n<p style=\"margin-bottom: 0em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/98a34095df5ea7e738f082d20478bc35-2.png\" class=\"aligncenter\" title=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe2\" alt=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe2\" \/><\/p>\n<h2>1.2 \u5e2e\u52a9\u547d\u4ee4<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u2013-help\u547d\u4ee4<\/strong><\/p>\n<pre>shutdown&nbsp;--help\uff1aifconfig&nbsp;--help\uff1a\u67e5\u770b\u7f51\u5361\u4fe1\u606f<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>man\u547d\u4ee4\uff08\u547d\u4ee4\u8bf4\u660e\u4e66\uff09<\/strong><\/p>\n<pre>man&nbsp;shutdown\u6ce8\u610f\uff1aman&nbsp;shutdown&nbsp;\u6253\u5f00\u547d\u4ee4\u8bf4\u660e\u4e66\u4e4b\u540e\uff0c\u4f7f\u7528\u6309\u952eq\u9000\u51fa<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h1>\u4e8c\u3001\u76ee\u5f55\u64cd\u4f5c\u547d\u4ee4<\/h1>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6211\u4eec\u77e5\u9053Linux\u7684\u76ee\u5f55\u7ed3\u6784\u4e3a\u6811\u72b6\u7ed3\u6784\uff0c\u6700\u9876\u7ea7\u7684\u76ee\u5f55\u4e3a\u6839\u76ee\u5f55 \/\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5176\u4ed6\u76ee\u5f55\u901a\u8fc7\u6302\u8f7d\u53ef\u4ee5\u5c06\u5b83\u4eec\u6dfb\u52a0\u5230\u6811\u4e2d\uff0c\u901a\u8fc7\u89e3\u9664\u6302\u8f7d\u53ef\u4ee5\u79fb\u9664\u5b83\u4eec\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9996\u5148\u6211\u4eec\u9700\u8981\u5148\u77e5\u9053\u4ec0\u4e48\u662f\u7edd\u5bf9\u8def\u5f84\u4e0e\u76f8\u5bf9\u8def\u5f84\u3002<\/p>\n<ul>\n<li>\n<p><strong>\u7edd\u5bf9\u8def\u5f84\uff1a<\/strong>\u8def\u5f84\u7684\u5199\u6cd5\uff0c\u7531\u6839\u76ee\u5f55 \/ \u5199\u8d77\uff0c\u4f8b\u5982\uff1a\/usr\/share\/doc \u8fd9\u4e2a\u76ee\u5f55\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u76f8\u5bf9\u8def\u5f84\uff1a<\/strong>\u8def\u5f84\u7684\u5199\u6cd5\uff0c\u4e0d\u662f\u7531<span>&nbsp;<\/span>\/<span>&nbsp;<\/span>\u5199\u8d77\uff0c\u4f8b\u5982\u7531\/usr\/share\/doc<span>&nbsp;<\/span>\u8981\u5230<span>&nbsp;<\/span>\/usr\/share\/man<span>&nbsp;<\/span>\u5e95\u4e0b\u65f6\uff0c\u53ef\u4ee5\u5199\u6210\uff1acd ..\/man<span>&nbsp;<\/span>\u8fd9\u5c31\u662f\u76f8\u5bf9\u8def\u5f84\u7684\u5199\u6cd5\u5566\uff01<\/p>\n<\/li>\n<\/ul>\n<h2>2.1 \u76ee\u5f55\u5207\u6362 cd<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u547d\u4ee4\uff1acd \u76ee\u5f55<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">cd\u662fChange Directory\u7684\u7f29\u5199\uff0c\u8fd9\u662f\u7528\u6765\u53d8\u6362\u5de5\u4f5c\u76ee\u5f55\u7684\u547d\u4ee4\u3002<\/p>\n<pre>cd&nbsp;\/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5207\u6362\u5230\u6839\u76ee\u5f55cd&nbsp;\/usr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5207\u6362\u5230\u6839\u76ee\u5f55\u4e0b\u7684usr\u76ee\u5f55cd&nbsp;..\/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5207\u6362\u5230\u4e0a\u4e00\u7ea7\u76ee\u5f55&nbsp;\u6216\u8005&nbsp;&nbsp;cd&nbsp;..cd&nbsp;~&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5207\u6362\u5230home\u76ee\u5f55cd&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5207\u6362\u5230\u4e0a\u6b21\u8bbf\u95ee\u7684\u76ee\u5f55<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>2.2 \u76ee\u5f55\u67e5\u770b ls [-al]<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u547d\u4ee4\uff1als [-al]<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5\uff1a<\/p>\n<pre>ls&nbsp;[-aAdfFhilnrRSt]&nbsp;\u76ee\u5f55\u540d\u79f0ls&nbsp;[--color={never,auto,always}]&nbsp;\u76ee\u5f55\u540d\u79f0ls&nbsp;[--full-time]&nbsp;\u76ee\u5f55\u540d\u79f0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">ls \u67e5\u770b\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u76ee\u5f55\u548c\u6587\u4ef6ls -a \u67e5\u770b\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u76ee\u5f55\u548c\u6587\u4ef6\uff08\u5305\u62ec\u9690\u85cf\u7684\u6587\u4ef6\uff09ls -l \u6216 ll \u5217\u8868\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u76ee\u5f55\u548c\u6587\u4ef6\uff08\u5217\u8868\u67e5\u770b\uff0c\u663e\u793a\u66f4\u591a\u4fe1\u606f\uff09ls \/dir \u67e5\u770b\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u76ee\u5f55\u548c\u6587\u4ef6 \u5982\uff1als \/usr<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06\u5bb6\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u5217\u51fa\u6765(\u542b\u5c5e\u6027\u4e0e\u9690\u85cf\u6863)<\/p>\n<pre>ls&nbsp;-al&nbsp;~<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>2.3 \u76ee\u5f55\u64cd\u4f5c\u3010\u589e\uff0c\u5220\uff0c\u6539\uff0c\u67e5\u3011<\/h2>\n<h3>2.3.1 \u521b\u5efa\u76ee\u5f55\u3010\u589e\u3011 mkdir<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5982\u679c\u60f3\u8981\u521b\u5efa\u65b0\u7684\u76ee\u5f55\u7684\u8bdd\uff0c\u90a3\u4e48\u5c31\u4f7f\u7528mkdir (make directory)\u5427\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5\uff1a<\/p>\n<pre>mkdir&nbsp;[-mp]&nbsp;\u76ee\u5f55\u540d\u79f0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-m \uff1a\u914d\u7f6e\u6587\u4ef6\u7684\u6743\u9650\u5594\uff01\u76f4\u63a5\u914d\u7f6e\uff0c\u4e0d\u9700\u8981\u770b\u9ed8\u8ba4\u6743\u9650 (umask) \u7684\u8138\u8272\uff5e<\/p>\n<\/li>\n<li>\n<p>-p \uff1a\u5e2e\u52a9\u4f60\u76f4\u63a5\u5c06\u6240\u9700\u8981\u7684\u76ee\u5f55(\u5305\u542b\u4e0a\u4e00\u7ea7\u76ee\u5f55)\u9012\u5f52\u521b\u5efa\u8d77\u6765\uff01<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b9e\u4f8b\uff1a\u8bf7\u5230\/tmp\u5e95\u4e0b\u5c1d\u8bd5\u521b\u5efa\u6570\u4e2a\u65b0\u76ee\u5f55\u770b\u770b\uff1a<\/p>\n<pre>cd&nbsp;\/tmp[root@www&nbsp;tmp]&nbsp;mkdir&nbsp;test&nbsp;&nbsp;&nbsp;&nbsp;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u52a0\u4e86\u8fd9\u4e2a -p \u7684\u9009\u9879\uff0c\u53ef\u4ee5\u81ea\u884c\u5e2e\u4f60\u521b\u5efa\u591a\u5c42\u76ee\u5f55\uff01&lt;\/p&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u5b9e\u4f8b\uff1a\u521b\u5efa\u6743\u9650\u4e3a&lt;span style=\"outline: 0px;\"&gt;&nbsp;&lt;\/span&gt;&lt;strong style=\"outline: 0px;color: rgb(191, 54, 12);\"&gt;rwx\u2013x\u2014x&lt;\/strong&gt;&lt;span style=\"outline: 0px;\"&gt;&nbsp;&lt;\/span&gt;\u7684\u76ee\u5f55\u3002&lt;\/p&gt;&lt;pre class=\"brush:php;toolbar:false;\"&gt;[root@www&nbsp;tmp]&nbsp;mkdir&nbsp;-m&nbsp;711&nbsp;test2[root@www&nbsp;tmp]&nbsp;ls&nbsp;-ldrwxr-xr-x&nbsp;&nbsp;3&nbsp;root&nbsp;&nbsp;root&nbsp;4096&nbsp;Jul&nbsp;18&nbsp;12:50&nbsp;testdrwxr-xr-x&nbsp;&nbsp;3&nbsp;root&nbsp;&nbsp;root&nbsp;4096&nbsp;Jul&nbsp;18&nbsp;12:53&nbsp;test1drwx--x--x&nbsp;&nbsp;2&nbsp;root&nbsp;&nbsp;root&nbsp;4096&nbsp;Jul&nbsp;18&nbsp;12:54&nbsp;test2<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e0a\u9762\u7684\u6743\u9650\u90e8\u5206\uff0c\u5982\u679c\u6ca1\u6709\u52a0\u4e0a -m \u6765\u5f3a\u5236\u914d\u7f6e\u5c5e\u6027\uff0c\u7cfb\u7edf\u4f1a\u4f7f\u7528\u9ed8\u8ba4\u5c5e\u6027\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5982\u679c\u6211\u4eec\u4f7f\u7528 -m \uff0c\u5982\u4e0a\u4f8b\u6211\u4eec\u7ed9\u4e88 -m 711 \u6765\u7ed9\u4e88\u65b0\u7684\u76ee\u5f55 drwx\u2013x\u2014x \u7684\u6743\u9650\u3002<\/p>\n<h3>2.3.2 \u5220\u9664\u76ee\u5f55\u6216\u6587\u4ef6\u3010\u5220\u3011rm<\/h3>\n<pre>&nbsp;rm&nbsp;[-fir]&nbsp;\u6587\u4ef6\u6216\u76ee\u5f55<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-f \uff1a\u5c31\u662f force \u7684\u610f\u601d\uff0c\u5ffd\u7565\u4e0d\u5b58\u5728\u7684\u6587\u4ef6\uff0c\u4e0d\u4f1a\u51fa\u73b0\u8b66\u544a\u4fe1\u606f\uff1b<\/p>\n<\/li>\n<li>\n<p>-i \uff1a\u4e92\u52a8\u6a21\u5f0f\uff0c\u5728\u5220\u9664\u524d\u4f1a\u8be2\u95ee\u4f7f\u7528\u8005\u662f\u5426\u52a8\u4f5c<\/p>\n<\/li>\n<li>\n<p>-r \uff1a\u9012\u5f52\u5220\u9664\u554a\uff01\u6700\u5e38\u7528\u5728\u76ee\u5f55\u7684\u5220\u9664\u4e86\uff01\u8fd9\u662f\u975e\u5e38\u5371\u9669\u7684\u9009\u9879\uff01\uff01\uff01<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u5220\u9664\u6587\u4ef6\uff1a<\/strong>rm \u6587\u4ef6 \u5220\u9664\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6rm -f \u6587\u4ef6 \u5220\u9664\u5f53\u524d\u76ee\u5f55\u7684\u7684\u6587\u4ef6\uff08\u4e0d\u8be2\u95ee\uff09<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u5220\u9664\u76ee\u5f55\uff1a<\/strong>rm -r aaa \u9012\u5f52\u5220\u9664\u5f53\u524d\u76ee\u5f55\u4e0b\u7684aaa\u76ee\u5f55rm -rf aaa \u9012\u5f52\u5220\u9664\u5f53\u524d\u76ee\u5f55\u4e0b\u7684aaa\u76ee\u5f55\uff08\u4e0d\u8be2\u95ee\uff09<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u5168\u90e8\u5220\u9664\uff1a<\/strong>rm -rf<span>&nbsp;<\/span><em>\u5c06\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u76ee\u5f55\u548c\u6587\u4ef6\u5168\u90e8\u5220\u9664rm -rf \/<\/em><span>&nbsp;<\/span><strong>\u3010\u614e\u7528\uff01\u614e\u7528\uff01\u614e\u7528\uff01\u3011<\/strong>\u5c06\u6839\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u5168\u90e8\u5220\u9664<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6ce8\u610f\uff1arm\u4e0d\u4ec5\u53ef\u4ee5\u5220\u9664\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u5220\u9664\u5176\u4ed6\u6587\u4ef6\u6216\u538b\u7f29\u5305\uff0c\u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u7684\u8bb0\u5fc6\uff0c\u65e0\u8bba\u5220\u9664\u4efb\u4f55\u76ee\u5f55\u6216\u6587\u4ef6\uff0c\u90fd\u76f4\u63a5\u4f7f\u7528 rm -rf \u76ee\u5f55\/\u6587\u4ef6\/\u538b\u7f29\u5305<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>rmdir (\u5220\u9664\u7a7a\u7684\u76ee\u5f55)<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5\uff1a<\/p>\n<pre>&nbsp;rmdir&nbsp;[-p]&nbsp;\u76ee\u5f55\u540d\u79f0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p><strong>-p \uff1a<\/strong>\u8fde\u540c\u4e0a\u4e00\u7ea7\u300e\u7a7a\u7684\u300f\u76ee\u5f55\u4e5f\u4e00\u8d77\u5220\u9664<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5220\u9664 runoob \u76ee\u5f55<\/p>\n<pre>[root@www&nbsp;tmp]&nbsp;rmdir&nbsp;runoob<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06 mkdir \u5b9e\u4f8b\u4e2d\u521b\u5efa\u7684\u76ee\u5f55(\/tmp \u5e95\u4e0b)\u5220\u9664\u6389\uff01<\/p>\n<pre>[root@www&nbsp;tmp]&nbsp;ls&nbsp;-l&nbsp;&nbsp;&nbsp;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u5229\u7528 -p \u8fd9\u4e2a\u9009\u9879\uff0c\u7acb\u523b\u5c31\u53ef\u4ee5\u5c06 test1\/test2\/test3\/test4 \u4e00\u6b21\u5220\u9664\u3002&lt;\/p&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u4e0d\u8fc7\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u4e2a rmdir \u4ec5\u80fd\u5220\u9664\u7a7a\u7684\u76ee\u5f55\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 rm \u547d\u4ee4\u6765\u5220\u9664\u975e\u7a7a\u76ee\u5f55\u3002&lt;\/p&gt;&lt;h3 style=\"outline: 0px;font-size: 18px;font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto rgb center&gt;2.3.3 \u76ee\u5f55\u4fee\u6539\u3010\u6539\u3011mv \u548c cp&lt;\/h3&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;&lt;strong style=\"outline: 0px;color: rgb(191, 54, 12);\"&gt;mv (\u79fb\u52a8\u6587\u4ef6\u4e0e\u76ee\u5f55\uff0c\u6216\u4fee\u6539\u540d\u79f0)&lt;\/strong&gt;&lt;\/p&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u8bed\u6cd5\uff1a&lt;\/p&gt;&lt;pre class=\"brush:php;toolbar:false;\"&gt;[root@www&nbsp;~]&nbsp;mv&nbsp;[-fiu]&nbsp;source&nbsp;destination[root@www&nbsp;~]&nbsp;mv&nbsp;[options]&nbsp;source1&nbsp;source2&nbsp;source3&nbsp;....&nbsp;directory<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-f \uff1aforce \u5f3a\u5236\u7684\u610f\u601d\uff0c\u5982\u679c\u76ee\u6807\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\uff0c\u4e0d\u4f1a\u8be2\u95ee\u800c\u76f4\u63a5\u8986\u76d6\uff1b<\/p>\n<\/li>\n<li>\n<p>-i \uff1a\u82e5\u76ee\u6807\u6587\u4ef6 (destination) \u5df2\u7ecf\u5b58\u5728\u65f6\uff0c\u5c31\u4f1a\u8be2\u95ee\u662f\u5426\u8986\u76d6\uff01<\/p>\n<\/li>\n<li>\n<p>-u \uff1a\u82e5\u76ee\u6807\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\uff0c\u4e14 source \u6bd4\u8f83\u65b0\uff0c\u624d\u4f1a\u5347\u7ea7 (update)<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>cp (\u590d\u5236\u6587\u4ef6\u6216\u76ee\u5f55)<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">cp \u5373\u62f7\u8d1d\u6587\u4ef6\u548c\u76ee\u5f55\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5:<\/p>\n<pre>[root@www&nbsp;~]&nbsp;cp&nbsp;[-adfilprsu]&nbsp;\u6765\u6e90\u6863(source)&nbsp;\u76ee\u6807\u6863(destination)[root@www&nbsp;~]&nbsp;cp&nbsp;[options]&nbsp;source1&nbsp;source2&nbsp;source3&nbsp;....&nbsp;directory<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-a\uff1a\u76f8\u5f53\u65bc -pdr \u7684\u610f\u601d\uff0c\u81f3\u65bc pdr \u8bf7\u53c2\u8003\u4e0b\u5217\u8bf4\u660e\uff1b(\u5e38\u7528)<\/p>\n<\/li>\n<li>\n<p>-d\uff1a\u82e5\u6765\u6e90\u6863\u4e3a\u8fde\u7ed3\u6863\u7684\u5c5e\u6027(link file)\uff0c\u5219\u590d\u5236\u8fde\u7ed3\u6863\u5c5e\u6027\u800c\u975e\u6587\u4ef6\u672c\u8eab\uff1b<\/p>\n<\/li>\n<li>\n<p>-f\uff1a\u4e3a\u5f3a\u5236(force)\u7684\u610f\u601d\uff0c\u82e5\u76ee\u6807\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\u4e14\u65e0\u6cd5\u5f00\u542f\uff0c\u5219\u79fb\u9664\u540e\u518d\u5c1d\u8bd5\u4e00\u6b21\uff1b<\/p>\n<\/li>\n<li>\n<p>-i\uff1a\u82e5\u76ee\u6807\u6863(destination)\u5df2\u7ecf\u5b58\u5728\u65f6\uff0c\u5728\u8986\u76d6\u65f6\u4f1a\u5148\u8be2\u95ee\u52a8\u4f5c\u7684\u8fdb\u884c(\u5e38\u7528)<\/p>\n<\/li>\n<li>\n<p>-l\uff1a\u8fdb\u884c\u786c\u5f0f\u8fde\u7ed3(hard link)\u7684\u8fde\u7ed3\u6863\u521b\u5efa\uff0c\u800c\u975e\u590d\u5236\u6587\u4ef6\u672c\u8eab\uff1b<\/p>\n<\/li>\n<li>\n<p>-p\uff1a\u8fde\u540c\u6587\u4ef6\u7684\u5c5e\u6027\u4e00\u8d77\u590d\u5236\u8fc7\u53bb\uff0c\u800c\u975e\u4f7f\u7528\u9ed8\u8ba4\u5c5e\u6027(\u5907\u4efd\u5e38\u7528)\uff1b<\/p>\n<\/li>\n<li>\n<p>-r\uff1a\u9012\u5f52\u6301\u7eed\u590d\u5236\uff0c\u7528\u65bc\u76ee\u5f55\u7684\u590d\u5236\u884c\u4e3a\uff1b(\u5e38\u7528)<\/p>\n<\/li>\n<li>\n<p>-s\uff1a\u590d\u5236\u6210\u4e3a\u7b26\u53f7\u8fde\u7ed3\u6863 (symbolic link)\uff0c\u4ea6\u5373\u300e\u6377\u5f84\u300f\u6587\u4ef6\uff1b<\/p>\n<\/li>\n<li>\n<p>-u\uff1a\u82e5 destination \u6bd4 source \u65e7\u624d\u5347\u7ea7 destination \uff01<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u4e00\u3001\u91cd\u547d\u540d\u76ee\u5f55<\/strong>\u547d\u4ee4\uff1amv \u5f53\u524d\u76ee\u5f55 \u65b0\u76ee\u5f55\u4f8b\u5982\uff1amv aaa bbb \u5c06\u76ee\u5f55aaa\u6539\u4e3abbb\u6ce8\u610f\uff1amv\u7684\u8bed\u6cd5\u4e0d\u4ec5\u53ef\u4ee5\u5bf9\u76ee\u5f55\u8fdb\u884c\u91cd\u547d\u540d\u800c\u4e14\u4e5f\u53ef\u4ee5\u5bf9\u5404\u79cd\u6587\u4ef6\uff0c\u538b\u7f29\u5305\u7b49\u8fdb\u884c \u91cd\u547d\u540d\u7684\u64cd\u4f5c<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u4e8c\u3001\u526a\u5207\u76ee\u5f55<\/strong>\u547d\u4ee4\uff1amv \u76ee\u5f55\u540d\u79f0 \u76ee\u5f55\u7684\u65b0\u4f4d\u7f6e\u793a\u4f8b\uff1a\u5c06\/usr\/tmp\u76ee\u5f55\u4e0b\u7684aaa\u76ee\u5f55\u526a\u5207\u5230 \/usr\u76ee\u5f55\u4e0b\u9762 mv \/usr\/tmp\/aaa \/usr\u6ce8\u610f\uff1amv\u8bed\u6cd5\u4e0d\u4ec5\u53ef\u4ee5\u5bf9\u76ee\u5f55\u8fdb\u884c\u526a\u5207\u64cd\u4f5c\uff0c\u5bf9\u6587\u4ef6\u548c\u538b\u7f29\u5305\u7b49\u90fd\u53ef\u6267\u884c\u526a\u5207\u64cd\u4f5c<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u4e09\u3001\u62f7\u8d1d\u76ee\u5f55<\/strong>\u547d\u4ee4\uff1acp -r \u76ee\u5f55\u540d\u79f0 \u76ee\u5f55\u62f7\u8d1d\u7684\u76ee\u6807\u4f4d\u7f6e -r\u4ee3\u8868\u9012\u5f52\u793a\u4f8b\uff1a\u5c06\/usr\/tmp\u76ee\u5f55\u4e0b\u7684aaa\u76ee\u5f55\u590d\u5236\u5230 \/usr\u76ee\u5f55\u4e0b\u9762 cp \/usr\/tmp\/aaa \/usr\u6ce8\u610f\uff1acp\u547d\u4ee4\u4e0d\u4ec5\u53ef\u4ee5\u62f7\u8d1d\u76ee\u5f55\u8fd8\u53ef\u4ee5\u62f7\u8d1d\u6587\u4ef6\uff0c\u538b\u7f29\u5305\u7b49\uff0c\u62f7\u8d1d\u6587\u4ef6\u548c\u538b\u7f29\u5305\u65f6\u4e0d \u7528\u5199-r\u9012\u5f52<\/p>\n<h3>2.3.4 \u641c\u7d22\u76ee\u5f55\u3010\u67e5\u3011find<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Linux find \u547d\u4ee4\u7528\u6765\u5728\u6307\u5b9a\u76ee\u5f55\u4e0b\u67e5\u627e\u6587\u4ef6\u3002\u4efb\u4f55\u4f4d\u4e8e\u53c2\u6570\u4e4b\u524d\u7684\u5b57\u7b26\u4e32\u90fd\u5c06\u88ab\u89c6\u4e3a\u6b32\u67e5\u627e\u7684\u76ee\u5f55\u540d\u3002\u5982\u679c\u4f7f\u7528\u8be5\u547d\u4ee4\u65f6\uff0c\u4e0d\u8bbe\u7f6e\u4efb\u4f55\u53c2\u6570\uff0c\u5219 find \u547d\u4ee4\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u67e5\u627e\u5b50\u76ee\u5f55\u4e0e\u6587\u4ef6\u3002\u5e76\u4e14\u5c06\u67e5\u627e\u5230\u7684\u5b50\u76ee\u5f55\u548c\u6587\u4ef6\u5168\u90e8\u8fdb\u884c\u663e\u793a\u3002<\/p>\n<pre>find&nbsp;&nbsp;&nbsp;path&nbsp;&nbsp;&nbsp;-option&nbsp;&nbsp;&nbsp;[&nbsp;&nbsp;&nbsp;-print&nbsp;]&nbsp;&nbsp;&nbsp;[&nbsp;-exec&nbsp;&nbsp;&nbsp;-ok&nbsp;&nbsp;&nbsp;command&nbsp;]&nbsp;&nbsp;&nbsp;{}&nbsp;;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u547d\u4ee4\uff1afind \u76ee\u5f55 \u53c2\u6570 \u6587\u4ef6\u540d\u79f0<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u90e8\u5206\u53c2\u6570\uff1a<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">find \u6839\u636e\u4e0b\u5217\u89c4\u5219\u5224\u65ad path \u548c expression\uff0c\u5728\u547d\u4ee4\u5217\u4e0a\u7b2c\u4e00\u4e2a &#8211; ( ) , ! \u4e4b\u524d\u7684\u90e8\u4efd\u4e3a path\uff0c\u4e4b\u540e\u7684\u662f expression\u3002\u5982\u679c path \u662f\u7a7a\u5b57\u4e32\u5219\u4f7f\u7528\u76ee\u524d\u8def\u5f84\uff0c\u5982\u679c expression \u662f\u7a7a\u5b57\u4e32\u5219\u4f7f\u7528 -print \u4e3a\u9884\u8bbe expression\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">expression \u4e2d\u53ef\u4f7f\u7528\u7684\u9009\u9879\u6709\u4e8c\u4e09\u5341\u4e2a\u4e4b\u591a\uff0c\u5728\u6b64\u53ea\u4ecb\u7ecd\u6700\u5e38\u7528\u7684\u90e8\u4efd\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">-mount, -xdev : \u53ea\u68c0\u67e5\u548c\u6307\u5b9a\u76ee\u5f55\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u4e0b\u7684\u6587\u4ef6\uff0c\u907f\u514d\u5217\u51fa\u5176\u5b83\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u6587\u4ef6<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">-amin n : \u5728\u8fc7\u53bb n \u5206\u949f\u5185\u88ab\u8bfb\u53d6\u8fc7<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">-anewer file : \u6bd4\u6587\u4ef6 file \u66f4\u665a\u88ab\u8bfb\u53d6\u8fc7\u7684\u6587\u4ef6<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">-atime n : \u5728\u8fc7\u53bbn\u5929\u5185\u88ab\u8bfb\u53d6\u8fc7\u7684\u6587\u4ef6<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">-cmin n : \u5728\u8fc7\u53bb n \u5206\u949f\u5185\u88ab\u4fee\u6539\u8fc7<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">-cnewer file :\u6bd4\u6587\u4ef6 file \u66f4\u65b0\u7684\u6587\u4ef6<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">-ctime n : \u5728\u8fc7\u53bbn\u5929\u5185\u88ab\u4fee\u6539\u8fc7\u7684\u6587\u4ef6<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u5b9e\u4f8b<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06\u76ee\u524d\u76ee\u5f55\u53ca\u5176\u5b50\u76ee\u5f55\u4e0b\u6240\u6709\u5ef6\u4f38\u6863\u540d\u662f c \u7684\u6587\u4ef6\u5217\u51fa\u6765\u3002<\/p>\n<pre>find&nbsp;.&nbsp;-name&nbsp;\"*.c\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06\u76ee\u524d\u76ee\u5f55\u5176\u5176\u4e0b\u5b50\u76ee\u5f55\u4e2d\u6240\u6709\u4e00\u822c\u6587\u4ef6\u5217\u51fa<\/p>\n<pre>find&nbsp;.&nbsp;-type&nbsp;f<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06\u76ee\u524d\u76ee\u5f55\u53ca\u5176\u5b50\u76ee\u5f55\u4e0b\u6240\u6709\u6700\u8fd1 20 \u5929\u5185\u66f4\u65b0\u8fc7\u7684\u6587\u4ef6\u5217\u51fa<\/p>\n<pre>find&nbsp;.&nbsp;-ctime&nbsp;-20<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>2.4 \u5f53\u524d\u76ee\u5f55\u663e\u793a pwd<\/h2>\n<h3>pwd (\u663e\u793a\u76ee\u524d\u6240\u5728\u7684\u76ee\u5f55)<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">pwd \u662f<span>&nbsp;<\/span><strong>Print Working Directory<\/strong><span>&nbsp;<\/span>\u7684\u7f29\u5199\uff0c\u4e5f\u5c31\u662f\u663e\u793a\u76ee\u524d\u6240\u5728\u76ee\u5f55\u7684\u547d\u4ee4\u3002<\/p>\n<pre>[root@www&nbsp;~]&nbsp;pwd&nbsp;[-P]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p><strong>-P<\/strong><span>&nbsp;<\/span>\uff1a\u663e\u793a\u51fa\u786e\u5b9e\u7684\u8def\u5f84\uff0c\u800c\u975e\u4f7f\u7528\u8fde\u7ed3 (link) \u8def\u5f84\u3002<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b9e\u4f8b\uff1a\u5355\u7eaf\u663e\u793a\u51fa\u76ee\u524d\u7684\u5de5\u4f5c\u76ee\u5f55\uff1a<\/p>\n<pre>[root@www&nbsp;~]&nbsp;pwd\/root&nbsp;&nbsp;&nbsp;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u5b9e\u4f8b\u663e\u793a\u51fa\u5b9e\u9645\u7684\u5de5\u4f5c\u76ee\u5f55\uff0c\u800c\u975e\u8fde\u7ed3\u6863\u672c\u8eab\u7684\u76ee\u5f55\u540d\u800c\u5df2\u3002&lt;\/p&gt;&lt;pre class=\"brush:php;toolbar:false;\"&gt;[root@www&nbsp;~]&nbsp;cd&nbsp;\/var\/mail&nbsp;&nbsp;&nbsp;&nbsp;spool\/mail#&nbsp;\u770b\u5230\u8fd9\u91cc\u5e94\u8be5\u77e5\u9053\u4e3a\u5565\u4e86\u5427\uff1f\u56e0\u4e3a&nbsp;\/var\/mail&nbsp;\u662f\u8fde\u7ed3\u6863\uff0c\u8fde\u7ed3\u5230&nbsp;\/var\/spool\/mail&nbsp;#&nbsp;\u6240\u4ee5\uff0c\u52a0\u4e0a&nbsp;pwd&nbsp;-P&nbsp;\u7684\u9009\u9879\u540e\uff0c\u4f1a\u4e0d\u4ee5\u8fde\u7ed3\u6863\u7684\u6570\u636e\u663e\u793a\uff0c\u800c\u662f\u663e\u793a\u6b63\u786e\u7684\u5b8c\u6574\u8def\u5f84\u554a\uff01<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h1>\u4e09\u3001\u6587\u4ef6\u64cd\u4f5c\u547d\u4ee4<\/h1>\n<h2>3.1 \u6587\u4ef6\u64cd\u4f5c\u3010\u589e\uff0c\u5220\uff0c\u6539\uff0c\u67e5\u3011<\/h2>\n<h3>3.1.1 \u65b0\u5efa\u6587\u4ef6\u3010\u589e\u3011touch<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Linux touch\u547d\u4ee4\u7528\u4e8e\u4fee\u6539\u6587\u4ef6\u6216\u8005\u76ee\u5f55\u7684\u65f6\u95f4\u5c5e\u6027\uff0c\u5305\u62ec\u5b58\u53d6\u65f6\u95f4\u548c\u66f4\u6539\u65f6\u95f4\u3002\u82e5\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u7cfb\u7edf\u4f1a\u5efa\u7acb\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">ls -l \u53ef\u4ee5\u663e\u793a\u6863\u6848\u7684\u65f6\u95f4\u8bb0\u5f55\u3002<\/p>\n<h4>\u8bed\u6cd5<\/h4>\n<pre>touch&nbsp;[-acfm][-d][-r]&nbsp;[-t][--help][--version][\u6587\u4ef6\u6216\u76ee\u5f55\u2026]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p><strong>\u53c2\u6570\u8bf4\u660e<\/strong>\uff1a<\/p>\n<\/li>\n<li>\n<p>a \u6539\u53d8\u6863\u6848\u7684\u8bfb\u53d6\u65f6\u95f4\u8bb0\u5f55\u3002<\/p>\n<\/li>\n<li>\n<p>m \u6539\u53d8\u6863\u6848\u7684\u4fee\u6539\u65f6\u95f4\u8bb0\u5f55\u3002<\/p>\n<\/li>\n<li>\n<p>c \u5047\u5982\u76ee\u7684\u6863\u6848\u4e0d\u5b58\u5728\uff0c\u4e0d\u4f1a\u5efa\u7acb\u65b0\u7684\u6863\u6848\u3002\u4e0e \u2014no-create \u7684\u6548\u679c\u4e00\u6837\u3002<\/p>\n<\/li>\n<li>\n<p>f \u4e0d\u4f7f\u7528\uff0c\u662f\u4e3a\u4e86\u4e0e\u5176\u4ed6 unix \u7cfb\u7edf\u7684\u76f8\u5bb9\u6027\u800c\u4fdd\u7559\u3002<\/p>\n<\/li>\n<li>\n<p>r \u4f7f\u7528\u53c2\u8003\u6863\u7684\u65f6\u95f4\u8bb0\u5f55\uff0c\u4e0e \u2014file \u7684\u6548\u679c\u4e00\u6837\u3002<\/p>\n<\/li>\n<li>\n<p>d \u8bbe\u5b9a\u65f6\u95f4\u4e0e\u65e5\u671f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u4e0d\u540c\u7684\u683c\u5f0f\u3002<\/p>\n<\/li>\n<li>\n<p>t \u8bbe\u5b9a\u6863\u6848\u7684\u65f6\u95f4\u8bb0\u5f55\uff0c\u683c\u5f0f\u4e0e date \u6307\u4ee4\u76f8\u540c\u3002<\/p>\n<\/li>\n<li>\n<p>\u2013no-create \u4e0d\u4f1a\u5efa\u7acb\u65b0\u6863\u6848\u3002<\/p>\n<\/li>\n<li>\n<p>\u2013help \u5217\u51fa\u6307\u4ee4\u683c\u5f0f\u3002<\/p>\n<\/li>\n<li>\n<p>\u2013version \u5217\u51fa\u7248\u672c\u8baf\u606f\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>\u5b9e\u4f8b<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528\u6307\u4ee4\u201dtouch\u201d\u4fee\u6539\u6587\u4ef6\u201dtestfile\u201d\u7684\u65f6\u95f4\u5c5e\u6027\u4e3a\u5f53\u524d\u7cfb\u7edf\u65f6\u95f4\uff0c\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$&nbsp;touch&nbsp;testfile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u4fee\u6539\u6587\u4ef6\u7684\u65f6\u95f4\u5c5e\u6027<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9996\u5148\uff0c\u4f7f\u7528ls\u547d\u4ee4\u67e5\u770btestfile\u6587\u4ef6\u7684\u5c5e\u6027\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>$&nbsp;ls&nbsp;-l&nbsp;testfile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u67e5\u770b\u6587\u4ef6\u7684\u65f6\u95f4\u5c5e\u6027&nbsp;&nbsp;#\u539f\u6765\u6587\u4ef6\u7684\u4fee\u6539\u65f6\u95f4\u4e3a16:09&nbsp;&nbsp;-rw-r--r--&nbsp;1&nbsp;hdd&nbsp;hdd&nbsp;55&nbsp;2011-08-22&nbsp;16:09&nbsp;testfile<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6267\u884c\u6307\u4ee4\u201dtouch\u201d\u4fee\u6539\u6587\u4ef6\u5c5e\u6027\u4ee5\u540e\uff0c\u5e76\u518d\u6b21\u67e5\u770b\u8be5\u6587\u4ef6\u7684\u65f6\u95f4\u5c5e\u6027\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>$&nbsp;touch&nbsp;testfile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u4fee\u6539\u6587\u4ef6\u65f6\u95f4\u5c5e\u6027\u4e3a\u5f53\u524d\u7cfb\u7edf\u65f6\u95f4&nbsp;&nbsp;$&nbsp;ls&nbsp;-l&nbsp;testfile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u67e5\u770b\u6587\u4ef6\u7684\u65f6\u95f4\u5c5e\u6027&nbsp;&nbsp;#\u4fee\u6539\u540e\u6587\u4ef6\u7684\u65f6\u95f4\u5c5e\u6027\u4e3a\u5f53\u524d\u7cfb\u7edf\u65f6\u95f4&nbsp;&nbsp;-rw-r--r--&nbsp;1&nbsp;hdd&nbsp;hdd&nbsp;55&nbsp;2011-08-22&nbsp;19:53&nbsp;testfile<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528\u6307\u4ee4\u201dtouch\u201d\u65f6\uff0c\u5982\u679c\u6307\u5b9a\u7684\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u5219\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7a7a\u767d\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u4f7f\u7528\u8be5\u6307\u4ee4\u521b\u5efa\u4e00\u4e2a\u7a7a\u767d\u6587\u4ef6\u201dfile\u201d\uff0c\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>$&nbsp;touch&nbsp;file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cfile\u201d\u7684\u65b0\u7684\u7a7a\u767d\u6587\u4ef6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>3.1.2 \u5220\u9664\u6587\u4ef6 \u3010\u5220\u3011 rm<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>rm (\u79fb\u9664\u6587\u4ef6\u6216\u76ee\u5f55)<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5\uff1a<\/p>\n<pre>&nbsp;rm&nbsp;[-fir]&nbsp;\u6587\u4ef6\u6216\u76ee\u5f55<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-f \uff1a\u5c31\u662f force \u7684\u610f\u601d\uff0c\u5ffd\u7565\u4e0d\u5b58\u5728\u7684\u6587\u4ef6\uff0c\u4e0d\u4f1a\u51fa\u73b0\u8b66\u544a\u4fe1\u606f\uff1b<\/p>\n<\/li>\n<li>\n<p>-i \uff1a\u4e92\u52a8\u6a21\u5f0f\uff0c\u5728\u5220\u9664\u524d\u4f1a\u8be2\u95ee\u4f7f\u7528\u8005\u662f\u5426\u52a8\u4f5c<\/p>\n<\/li>\n<li>\n<p>-r \uff1a\u9012\u5f52\u5220\u9664\u554a\uff01\u6700\u5e38\u7528\u5728\u76ee\u5f55\u7684\u5220\u9664\u4e86\uff01\u8fd9\u662f\u975e\u5e38\u5371\u9669\u7684\u9009\u9879\uff01\uff01\uff01<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06\u521b\u5efa\u7684 bashrc \u5220\u9664\u6389\uff01<\/p>\n<pre>[root@www&nbsp;tmp]#&nbsp;rm&nbsp;-i&nbsp;bashrcrm:&nbsp;remove&nbsp;regular&nbsp;file&nbsp;`bashrc'?&nbsp;y<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5982\u679c\u52a0\u4e0a -i \u7684\u9009\u9879\u5c31\u4f1a\u4e3b\u52a8\u8be2\u95ee\u5594\uff0c\u907f\u514d\u4f60\u5220\u9664\u5230\u9519\u8bef\u7684\u6863\u540d\uff01<\/p>\n<h3>3.1.3 \u4fee\u6539\u6587\u4ef6\u3010\u6539\u3011 vi\u6216vim<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u5148\u6765\u4e2avim\u952e\u76d8\u56fe\uff01<\/strong><\/p>\n<p style=\"margin-bottom: 0em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/98a34095df5ea7e738f082d20478bc35-3.png\" class=\"aligncenter\" title=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe3\" alt=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe3\" \/><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>vi\/vim \u7684\u4f7f\u7528<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u57fa\u672c\u4e0a vi\/vim \u5171\u5206\u4e3a\u4e09\u79cd\u6a21\u5f0f\uff0c\u5206\u522b\u662f<strong>\u547d\u4ee4\u6a21\u5f0f\uff08Command mode\uff09<\/strong>\uff0c<strong>\u8f93\u5165\u6a21\u5f0f\uff08Insert mode\uff09<\/strong>\u548c<span>&nbsp;<\/span><strong>\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\uff08Last line mode\uff09<\/strong>\u3002\u8fd9\u4e09\u79cd\u6a21\u5f0f\u7684\u4f5c\u7528\u5206\u522b\u662f\uff1a<\/p>\n<h4>3.1.3.1 \u547d\u4ee4\u6a21\u5f0f\uff1a<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7528\u6237\u521a\u521a\u542f\u52a8 vi\/vim\uff0c\u4fbf\u8fdb\u5165\u4e86\u547d\u4ee4\u6a21\u5f0f\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6b64\u72b6\u6001\u4e0b\u6572\u51fb\u952e\u76d8\u52a8\u4f5c\u4f1a\u88abVim\u8bc6\u522b\u4e3a\u547d\u4ee4\uff0c\u800c\u975e\u8f93\u5165\u5b57\u7b26\u3002\u6bd4\u5982\u6211\u4eec\u6b64\u65f6\u6309\u4e0bi\uff0c\u5e76\u4e0d\u4f1a\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\uff0ci\u88ab\u5f53\u4f5c\u4e86\u4e00\u4e2a\u547d\u4ee4\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4ee5\u4e0b\u662f\u5e38\u7528\u7684\u51e0\u4e2a\u547d\u4ee4\uff1a<\/p>\n<ul>\n<li>\n<p><strong>i<\/strong><span>&nbsp;<\/span>\u5207\u6362\u5230\u8f93\u5165\u6a21\u5f0f\uff0c\u4ee5\u8f93\u5165\u5b57\u7b26\u3002<\/p>\n<\/li>\n<li>\n<p><strong>x<\/strong><span>&nbsp;<\/span>\u5220\u9664\u5f53\u524d\u5149\u6807\u6240\u5728\u5904\u7684\u5b57\u7b26\u3002<\/p>\n<\/li>\n<li>\n<p><strong>:<\/strong><span>&nbsp;<\/span>\u5207\u6362\u5230\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\uff0c\u4ee5\u5728\u6700\u5e95\u4e00\u884c\u8f93\u5165\u547d\u4ee4\u3002<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u82e5\u60f3\u8981\u7f16\u8f91\u6587\u672c\uff1a\u542f\u52a8Vim\uff0c\u8fdb\u5165\u4e86\u547d\u4ee4\u6a21\u5f0f\uff0c\u6309\u4e0bi\uff0c\u5207\u6362\u5230\u8f93\u5165\u6a21\u5f0f\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u547d\u4ee4\u6a21\u5f0f\u53ea\u6709\u4e00\u4e9b\u6700\u57fa\u672c\u7684\u547d\u4ee4\uff0c\u56e0\u6b64\u4ecd\u8981\u4f9d\u9760\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u8f93\u5165\u66f4\u591a\u547d\u4ee4\u3002<\/p>\n<h4>3.1.3.2 \u8f93\u5165\u6a21\u5f0f<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\u6309\u4e0bi\u5c31\u8fdb\u5165\u4e86\u8f93\u5165\u6a21\u5f0f\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5728\u8f93\u5165\u6a21\u5f0f\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6309\u952e\uff1a<\/p>\n<ul>\n<li>\n<p><strong>\u5b57\u7b26\u6309\u952e\u4ee5\u53caShift\u7ec4\u5408<\/strong>\uff0c\u8f93\u5165\u5b57\u7b26<\/p>\n<\/li>\n<li>\n<p><strong>ENTER<\/strong>\uff0c\u56de\u8f66\u952e\uff0c\u6362\u884c<\/p>\n<\/li>\n<li>\n<p><strong>BACK SPACE<\/strong>\uff0c\u9000\u683c\u952e\uff0c\u5220\u9664\u5149\u6807\u524d\u4e00\u4e2a\u5b57\u7b26<\/p>\n<\/li>\n<li>\n<p><strong>DEL<\/strong>\uff0c\u5220\u9664\u952e\uff0c\u5220\u9664\u5149\u6807\u540e\u4e00\u4e2a\u5b57\u7b26<\/p>\n<\/li>\n<li>\n<p><strong>\u65b9\u5411\u952e<\/strong>\uff0c\u5728\u6587\u672c\u4e2d\u79fb\u52a8\u5149\u6807<\/p>\n<\/li>\n<li>\n<p><strong>HOME<\/strong>\/<strong>END<\/strong>\uff0c\u79fb\u52a8\u5149\u6807\u5230\u884c\u9996\/\u884c\u5c3e<\/p>\n<\/li>\n<li>\n<p><strong>Page Up<\/strong>\/<strong>Page Down<\/strong>\uff0c\u4e0a\/\u4e0b\u7ffb\u9875<\/p>\n<\/li>\n<li>\n<p><strong>Insert<\/strong>\uff0c\u5207\u6362\u5149\u6807\u4e3a\u8f93\u5165\/\u66ff\u6362\u6a21\u5f0f\uff0c\u5149\u6807\u5c06\u53d8\u6210\u7ad6\u7ebf\/\u4e0b\u5212\u7ebf<\/p>\n<\/li>\n<li>\n<p><strong>ESC<\/strong>\uff0c\u9000\u51fa\u8f93\u5165\u6a21\u5f0f\uff0c\u5207\u6362\u5230\u547d\u4ee4\u6a21\u5f0f<\/p>\n<\/li>\n<\/ul>\n<h4>3.1.3.4 \u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\u6309\u4e0b:\uff08\u82f1\u6587\u5192\u53f7\uff09\u5c31\u8fdb\u5165\u4e86\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u53ef\u4ee5\u8f93\u5165\u5355\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u7684\u547d\u4ee4\uff0c\u53ef\u7528\u7684\u547d\u4ee4\u975e\u5e38\u591a\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5728\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u4e2d\uff0c\u57fa\u672c\u7684\u547d\u4ee4\u6709\uff08\u5df2\u7ecf\u7701\u7565\u4e86\u5192\u53f7\uff09\uff1a<\/p>\n<ul>\n<li>\n<p>q \u9000\u51fa\u7a0b\u5e8f<\/p>\n<\/li>\n<li>\n<p>w \u4fdd\u5b58\u6587\u4ef6<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6309ESC\u952e\u53ef\u968f\u65f6\u9000\u51fa\u5e95\u7ebf\u547d\u4ee4\u6a21\u5f0f\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7b80\u5355\u7684\u8bf4\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u8fd9\u4e09\u4e2a\u6a21\u5f0f\u60f3\u6210\u5e95\u4e0b\u7684\u56fe\u6807\u6765\u8868\u793a\uff1a<\/p>\n<p style=\"margin-bottom: 0em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/b011e4f652f72a7197b89fb312877ab7-4.png\" class=\"aligncenter\" title=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe4\" alt=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe4\" \/><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u6253\u5f00\u6587\u4ef6<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u547d\u4ee4\uff1avi \u6587\u4ef6\u540d\u793a\u4f8b\uff1a\u6253\u5f00\u5f53\u524d\u76ee\u5f55\u4e0b\u7684aa.txt\u6587\u4ef6 vi aa.txt \u6216\u8005 vim aa.txt<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6ce8\u610f\uff1a\u4f7f\u7528vi\u7f16\u8f91\u5668\u6253\u5f00\u6587\u4ef6\u540e\uff0c\u5e76\u4e0d\u80fd\u7f16\u8f91\uff0c\u56e0\u4e3a\u6b64\u65f6\u5904\u4e8e\u547d\u4ee4\u6a21\u5f0f\uff0c\u70b9\u51fb\u952e\u76d8i\/a\/o\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u7f16\u8f91\u6587\u4ef6<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528vi\u7f16\u8f91\u5668\u6253\u5f00\u6587\u4ef6\u540e\u70b9\u51fb\u6309\u952e\uff1ai \uff0ca\u6216\u8005o\u5373\u53ef\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">i:\u5728\u5149\u6807\u6240\u5728\u5b57\u7b26\u524d\u5f00\u59cb\u63d2\u5165a:\u5728\u5149\u6807\u6240\u5728\u5b57\u7b26\u540e\u5f00\u59cb\u63d2\u5165o:\u5728\u5149\u6807\u6240\u5728\u884c\u7684\u4e0b\u9762\u53e6\u8d77\u4e00\u65b0\u884c\u63d2\u5165<\/p>\n<p style=\"margin-bottom: 0em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/cdbea8413fad419de056bdc6e5eeb325-5.png\" class=\"aligncenter\" title=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe5\" alt=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe5\" \/><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4fdd\u5b58\u6216\u8005\u53d6\u6d88\u7f16\u8f91<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u4fdd\u5b58\u6587\u4ef6\uff1a<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7b2c\u4e00\u6b65\uff1aESC \u8fdb\u5165\u547d\u4ee4\u884c\u6a21\u5f0f\u7b2c\u4e8c\u6b65\uff1a: \u8fdb\u5165\u5e95\u884c\u6a21\u5f0f\u7b2c\u4e09\u6b65\uff1awq \u4fdd\u5b58\u5e76\u9000\u51fa\u7f16\u8f91<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u53d6\u6d88\u7f16\u8f91\uff1a<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7b2c\u4e00\u6b65\uff1aESC \u8fdb\u5165\u547d\u4ee4\u884c\u6a21\u5f0f\u7b2c\u4e8c\u6b65\uff1a: \u8fdb\u5165\u5e95\u884c\u6a21\u5f0f\u7b2c\u4e09\u6b65\uff1aq! \u64a4\u9500\u672c\u6b21\u4fee\u6539\u5e76\u9000\u51fa\u7f16\u8f91<\/p>\n<h3>3.1.4 \u6587\u4ef6\u7684\u67e5\u770b\u3010\u67e5\u3011<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Linux\u7cfb\u7edf\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u6587\u4ef6\u7684\u5185\u5bb9\uff1a<\/p>\n<ul>\n<li>\n<p>cat \u7531\u7b2c\u4e00\u884c\u5f00\u59cb\u663e\u793a\u6587\u4ef6\u5185\u5bb9<\/p>\n<\/li>\n<li>\n<p>tac \u4ece\u6700\u540e\u4e00\u884c\u5f00\u59cb\u663e\u793a\uff0c\u53ef\u4ee5\u770b\u51fa tac \u662f cat \u7684\u5012\u7740\u5199\uff01<\/p>\n<\/li>\n<li>\n<p>nl \u663e\u793a\u7684\u65f6\u5019\uff0c\u987a\u9053\u8f93\u51fa\u884c\u53f7\uff01<\/p>\n<\/li>\n<li>\n<p>more \u4e00\u9875\u4e00\u9875\u7684\u663e\u793a\u6587\u4ef6\u5185\u5bb9<\/p>\n<\/li>\n<li>\n<p>less \u4e0e more \u7c7b\u4f3c\uff0c\u4f46\u662f\u6bd4 more \u66f4\u597d\u7684\u662f\uff0c\u4ed6\u53ef\u4ee5\u5f80\u524d\u7ffb\u9875\uff01<\/p>\n<\/li>\n<li>\n<p>head \u53ea\u770b\u5934\u51e0\u884c<\/p>\n<\/li>\n<li>\n<p>tail \u53ea\u770b\u5c3e\u5df4\u51e0\u884c<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f60\u53ef\u4ee5\u4f7f\u7528<span>&nbsp;<\/span><em>man [\u547d\u4ee4]<\/em>\u6765\u67e5\u770b\u5404\u4e2a\u547d\u4ee4\u7684\u4f7f\u7528\u6587\u6863\uff0c\u5982 \uff1aman cp\u3002<\/p>\n<h4>3.1.4.1 cat<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7531\u7b2c\u4e00\u884c\u5f00\u59cb\u663e\u793a\u6587\u4ef6\u5185\u5bb9<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5\uff1a<\/p>\n<pre>cat&nbsp;[-AbEnTv]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-A \uff1a\u76f8\u5f53\u65bc -vET \u7684\u6574\u5408\u9009\u9879\uff0c\u53ef\u5217\u51fa\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u800c\u4e0d\u662f\u7a7a\u767d\u800c\u5df2\uff1b<\/p>\n<\/li>\n<li>\n<p>-b \uff1a\u5217\u51fa\u884c\u53f7\uff0c\u4ec5\u9488\u5bf9\u975e\u7a7a\u767d\u884c\u505a\u884c\u53f7\u663e\u793a\uff0c\u7a7a\u767d\u884c\u4e0d\u6807\u884c\u53f7\uff01<\/p>\n<\/li>\n<li>\n<p>-E \uff1a\u5c06\u7ed3\u5c3e\u7684\u65ad\u884c\u5b57\u8282 $ \u663e\u793a\u51fa\u6765\uff1b<\/p>\n<\/li>\n<li>\n<p>-n \uff1a\u5217\u5370\u51fa\u884c\u53f7\uff0c\u8fde\u540c\u7a7a\u767d\u884c\u4e5f\u4f1a\u6709\u884c\u53f7\uff0c\u4e0e -b \u7684\u9009\u9879\u4e0d\u540c\uff1b<\/p>\n<\/li>\n<li>\n<p>-T \uff1a\u5c06 [tab] \u6309\u952e\u4ee5 ^I \u663e\u793a\u51fa\u6765\uff1b<\/p>\n<\/li>\n<li>\n<p>-v \uff1a\u5217\u51fa\u4e00\u4e9b\u770b\u4e0d\u51fa\u6765\u7684\u7279\u6b8a\u5b57\u7b26<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u68c0\u770b \/etc\/issue \u8fd9\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\uff1a<\/p>\n<pre>[root@www&nbsp;~]&nbsp;cat&nbsp;\/etc\/issueCentOS&nbsp;release&nbsp;6.4&nbsp;(Final)Kernel&nbsp;\r&nbsp;on&nbsp;an&nbsp;m<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4>3.1.3.2 tac<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">tac\u4e0ecat\u547d\u4ee4\u521a\u597d\u76f8\u53cd\uff0c\u6587\u4ef6\u5185\u5bb9\u4ece\u6700\u540e\u4e00\u884c\u5f00\u59cb\u663e\u793a\uff0c\u53ef\u4ee5\u770b\u51fa tac \u662f cat \u7684\u5012\u7740\u5199\uff01\u5982\uff1a<\/p>\n<pre>[root@www&nbsp;~]&nbsp;tac&nbsp;\/etc\/issueKernel&nbsp;\r&nbsp;on&nbsp;an&nbsp;mCentOS&nbsp;release&nbsp;6.4&nbsp;(Final)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4>3.1.3.3 nl<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u663e\u793a\u884c\u53f7<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5\uff1a<\/p>\n<pre>nl&nbsp;[-bnw]&nbsp;\u6587\u4ef6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-b \uff1a\u6307\u5b9a\u884c\u53f7\u6307\u5b9a\u7684\u65b9\u5f0f\uff0c\u4e3b\u8981\u6709\u4e24\u79cd\uff1a-b a \uff1a\u8868\u793a\u4e0d\u8bba\u662f\u5426\u4e3a\u7a7a\u884c\uff0c\u4e5f\u540c\u6837\u5217\u51fa\u884c\u53f7(\u7c7b\u4f3c cat -n)\uff1b-b t \uff1a\u5982\u679c\u6709\u7a7a\u884c\uff0c\u7a7a\u7684\u90a3\u4e00\u884c\u4e0d\u8981\u5217\u51fa\u884c\u53f7(\u9ed8\u8ba4\u503c)\uff1b<\/p>\n<\/li>\n<li>\n<p>-n \uff1a\u5217\u51fa\u884c\u53f7\u8868\u793a\u7684\u65b9\u6cd5\uff0c\u4e3b\u8981\u6709\u4e09\u79cd\uff1a-n ln \uff1a\u884c\u53f7\u5728\u8367\u5e55\u7684\u6700\u5de6\u65b9\u663e\u793a\uff1b-n rn \uff1a\u884c\u53f7\u5728\u81ea\u5df1\u680f\u4f4d\u7684\u6700\u53f3\u65b9\u663e\u793a\uff0c\u4e14\u4e0d\u52a0 0 \uff1b-n rz \uff1a\u884c\u53f7\u5728\u81ea\u5df1\u680f\u4f4d\u7684\u6700\u53f3\u65b9\u663e\u793a\uff0c\u4e14\u52a0 0 \uff1b<\/p>\n<\/li>\n<li>\n<p>-w \uff1a\u884c\u53f7\u680f\u4f4d\u7684\u5360\u7528\u7684\u4f4d\u6570\u3002<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b9e\u4f8b\u4e00\uff1a\u7528 nl \u5217\u51fa \/etc\/issue \u7684\u5185\u5bb9<\/p>\n<pre>\u725b\u903c\u554a\uff01\u63a5\u79c1\u6d3b\u5fc5\u5907\u7684&nbsp;N&nbsp;\u4e2a\u5f00\u6e90\u9879\u76ee\uff01\u8d76\u5feb\u6536\u85cf\u5427<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>[root@www&nbsp;~]&nbsp;nl&nbsp;\/etc\/issue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;CentOS&nbsp;release&nbsp;6.4&nbsp;(Final)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;Kernel&nbsp;\r&nbsp;on&nbsp;an&nbsp;m123<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4>3.1.3.5 more<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e00\u9875\u4e00\u9875\u7ffb\u52a8<\/p>\n<pre>[root@www&nbsp;~]&nbsp;more&nbsp;\/etc\/man_db.config&nbsp;##&nbsp;Generated&nbsp;automatically&nbsp;from&nbsp;man.conf.in&nbsp;by&nbsp;the#&nbsp;configure&nbsp;script.##&nbsp;man.conf&nbsp;from&nbsp;man-1.6d....(\u4e2d\u95f4\u7701\u7565)....--More--(28%)&nbsp;&nbsp;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u5728 more \u8fd9\u4e2a\u7a0b\u5e8f\u7684\u8fd0\u884c\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u6709\u51e0\u4e2a\u6309\u952e\u53ef\u4ee5\u6309\u7684\uff1a&lt;\/p&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p>\u7a7a\u767d\u952e (space)\uff1a\u4ee3\u8868\u5411\u4e0b\u7ffb\u4e00\u9875\uff1b<\/p>\n<\/li>\n<li>\n<p>Enter \uff1a\u4ee3\u8868\u5411\u4e0b\u7ffb\u300e\u4e00\u884c\u300f\uff1b<\/p>\n<\/li>\n<li>\n<p>\/\u5b57\u4e32 \uff1a\u4ee3\u8868\u5728\u8fd9\u4e2a\u663e\u793a\u7684\u5185\u5bb9\u5f53\u4e2d\uff0c\u5411\u4e0b\u641c\u5bfb\u300e\u5b57\u4e32\u300f\u8fd9\u4e2a\u5173\u952e\u5b57\uff1b<\/p>\n<\/li>\n<li>\n<p>:f \uff1a\u7acb\u523b\u663e\u793a\u51fa\u6863\u540d\u4ee5\u53ca\u76ee\u524d\u663e\u793a\u7684\u884c\u6570\uff1b<\/p>\n<\/li>\n<li>\n<p>q \uff1a\u4ee3\u8868\u7acb\u523b\u79bb\u5f00 more \uff0c\u4e0d\u518d\u663e\u793a\u8be5\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<\/li>\n<li>\n<p>b \u6216 [ctrl]-b \uff1a\u4ee3\u8868\u5f80\u56de\u7ffb\u9875\uff0c\u4e0d\u8fc7\u8fd9\u52a8\u4f5c\u53ea\u5bf9\u6587\u4ef6\u6709\u7528\uff0c\u5bf9\u7ba1\u7ebf\u65e0\u7528\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>3.1.3.6 less<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e00\u9875\u4e00\u9875\u7ffb\u52a8\uff0c\u4ee5\u4e0b\u5b9e\u4f8b\u8f93\u51fa\/etc\/man.config\u6587\u4ef6\u7684\u5185\u5bb9\uff1a<\/p>\n<pre>[root@www&nbsp;~]&nbsp;less&nbsp;\/etc\/man.config##&nbsp;Generated&nbsp;automatically&nbsp;from&nbsp;man.conf.in&nbsp;by&nbsp;the#&nbsp;configure&nbsp;script.##&nbsp;man.conf&nbsp;from&nbsp;man-1.6d....(\u4e2d\u95f4\u7701\u7565)....:&nbsp;&nbsp;&nbsp;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;less\u8fd0\u884c\u65f6\u53ef\u4ee5\u8f93\u5165\u7684\u547d\u4ee4\u6709\uff1a&lt;\/p&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p>\u7a7a\u767d\u952e \uff1a\u5411\u4e0b\u7ffb\u52a8\u4e00\u9875\uff1b<\/p>\n<\/li>\n<li>\n<p>[pagedown]\uff1a\u5411\u4e0b\u7ffb\u52a8\u4e00\u9875\uff1b<\/p>\n<\/li>\n<li>\n<p>[pageup] \uff1a\u5411\u4e0a\u7ffb\u52a8\u4e00\u9875\uff1b<\/p>\n<\/li>\n<li>\n<p>\/\u5b57\u4e32 \uff1a\u5411\u4e0b\u641c\u5bfb\u300e\u5b57\u4e32\u300f\u7684\u529f\u80fd\uff1b<\/p>\n<\/li>\n<li>\n<p>?\u5b57\u4e32 \uff1a\u5411\u4e0a\u641c\u5bfb\u300e\u5b57\u4e32\u300f\u7684\u529f\u80fd\uff1b<\/p>\n<\/li>\n<li>\n<p>n \uff1a\u91cd\u590d\u524d\u4e00\u4e2a\u641c\u5bfb (\u4e0e \/ \u6216 ? \u6709\u5173\uff01)<\/p>\n<\/li>\n<li>\n<p>N \uff1a\u53cd\u5411\u7684\u91cd\u590d\u524d\u4e00\u4e2a\u641c\u5bfb (\u4e0e \/ \u6216 ? \u6709\u5173\uff01)<\/p>\n<\/li>\n<li>\n<p>q \uff1a\u79bb\u5f00 less \u8fd9\u4e2a\u7a0b\u5e8f\uff1b<\/p>\n<\/li>\n<\/ul>\n<h4>3.1.3.7 head<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53d6\u51fa\u6587\u4ef6\u524d\u9762\u51e0\u884c<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5\uff1a<\/p>\n<pre>head&nbsp;[-n&nbsp;number]&nbsp;\u6587\u4ef6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-n \uff1a\u540e\u9762\u63a5\u6570\u5b57\uff0c\u4ee3\u8868\u663e\u793a\u51e0\u884c\u7684\u610f\u601d<\/p>\n<\/li>\n<\/ul>\n<pre>[root@www&nbsp;~]&nbsp;head&nbsp;\/etc\/man.config<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9ed8\u8ba4\u7684\u60c5\u51b5\u4e2d\uff0c\u663e\u793a\u524d\u9762 10 \u884c\uff01\u82e5\u8981\u663e\u793a\u524d 20 \u884c\uff0c\u5c31\u5f97\u8981\u8fd9\u6837\uff1a<\/p>\n<pre>[root@www&nbsp;~]&nbsp;head&nbsp;-n&nbsp;20&nbsp;\/etc\/man.config<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4>3.1.3.8 tail<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53d6\u51fa\u6587\u4ef6\u540e\u9762\u51e0\u884c<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8bed\u6cd5\uff1a<\/p>\n<pre>tail&nbsp;[-n&nbsp;number]&nbsp;\u6587\u4ef6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9009\u9879\u4e0e\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>-n \uff1a\u540e\u9762\u63a5\u6570\u5b57\uff0c\u4ee3\u8868\u663e\u793a\u51e0\u884c\u7684\u610f\u601d<\/p>\n<\/li>\n<li>\n<p>-f \uff1a\u8868\u793a\u6301\u7eed\u4fa6\u6d4b\u540e\u9762\u6240\u63a5\u7684\u6863\u540d\uff0c\u8981\u7b49\u5230\u6309\u4e0b[ctrl]-c\u624d\u4f1a\u7ed3\u675ftail\u7684\u4fa6\u6d4b<\/p>\n<\/li>\n<\/ul>\n<pre>[root@www&nbsp;~]&nbsp;tail&nbsp;\/etc\/man.config#&nbsp;\u9ed8\u8ba4\u7684\u60c5\u51b5\u4e2d\uff0c\u663e\u793a\u6700\u540e\u7684\u5341\u884c\uff01\u82e5\u8981\u663e\u793a\u6700\u540e\u7684&nbsp;20&nbsp;\u884c\uff0c\u5c31\u5f97\u8981\u8fd9\u6837\uff1a[root@www&nbsp;~]&nbsp;tail&nbsp;-n&nbsp;20&nbsp;\/etc\/man.config<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>3.2 \u6743\u9650\u4fee\u6539<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Linux\/Unix \u7684\u6587\u4ef6\u8c03\u7528\u6743\u9650\u5206\u4e3a\u4e09\u7ea7 : \u6587\u4ef6\u62e5\u6709\u8005\u3001\u7fa4\u7ec4\u3001\u5176\u4ed6\u3002\u5229\u7528 chmod \u53ef\u4ee5\u85c9\u4ee5\u63a7\u5236\u6587\u4ef6\u5982\u4f55\u88ab\u4ed6\u4eba\u6240\u8c03\u7528\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u4f7f\u7528\u6743\u9650<\/strong><span>&nbsp;<\/span>: \u6240\u6709\u4f7f\u7528\u8005<\/p>\n<h4>\u8bed\u6cd5<\/h4>\n<pre>chmod&nbsp;[-cfvR]&nbsp;[--help]&nbsp;[--version]&nbsp;mode&nbsp;file...<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4>\u53c2\u6570\u8bf4\u660e<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">mode : \u6743\u9650\u8bbe\u5b9a\u5b57\u4e32\uff0c\u683c\u5f0f\u5982\u4e0b :<\/p>\n<pre>[ugoa...][[+-=][rwxX]...][,...]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>\n<p>u \u8868\u793a\u8be5\u6587\u4ef6\u7684\u62e5\u6709\u8005\uff0cg \u8868\u793a\u4e0e\u8be5\u6587\u4ef6\u7684\u62e5\u6709\u8005\u5c5e\u4e8e\u540c\u4e00\u4e2a\u7fa4\u4f53(group)\u8005\uff0co \u8868\u793a\u5176\u4ed6\u4ee5\u5916\u7684\u4eba\uff0ca \u8868\u793a\u8fd9\u4e09\u8005\u7686\u662f\u3002<\/p>\n<\/li>\n<li>\n<p>+ \u8868\u793a\u589e\u52a0\u6743\u9650\u3001- \u8868\u793a\u53d6\u6d88\u6743\u9650\u3001= \u8868\u793a\u552f\u4e00\u8bbe\u5b9a\u6743\u9650\u3002<\/p>\n<\/li>\n<li>\n<p>r \u8868\u793a\u53ef\u8bfb\u53d6\uff0cw \u8868\u793a\u53ef\u5199\u5165\uff0cx \u8868\u793a\u53ef\u6267\u884c\uff0cX \u8868\u793a\u53ea\u6709\u5f53\u8be5\u6587\u4ef6\u662f\u4e2a\u5b50\u76ee\u5f55\u6216\u8005\u8be5\u6587\u4ef6\u5df2\u7ecf\u88ab\u8bbe\u5b9a\u8fc7\u4e3a\u53ef\u6267\u884c\u3002<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5176\u4ed6\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<ul>\n<li>\n<p>-c : \u82e5\u8be5\u6587\u4ef6\u6743\u9650\u786e\u5b9e\u5df2\u7ecf\u66f4\u6539\uff0c\u624d\u663e\u793a\u5176\u66f4\u6539\u52a8\u4f5c<\/p>\n<\/li>\n<li>\n<p>-f : \u82e5\u8be5\u6587\u4ef6\u6743\u9650\u65e0\u6cd5\u88ab\u66f4\u6539\u4e5f\u4e0d\u8981\u663e\u793a\u9519\u8bef\u8baf\u606f<\/p>\n<\/li>\n<li>\n<p>-v : \u663e\u793a\u6743\u9650\u53d8\u66f4\u7684\u8be6\u7ec6\u8d44\u6599<\/p>\n<\/li>\n<li>\n<p>-R : \u5bf9\u76ee\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u4e0e\u5b50\u76ee\u5f55\u8fdb\u884c\u76f8\u540c\u7684\u6743\u9650\u53d8\u66f4(\u5373\u4ee5\u9012\u56de\u7684\u65b9\u5f0f\u9010\u4e2a\u53d8\u66f4)<\/p>\n<\/li>\n<li>\n<p>\u2013help : \u663e\u793a\u8f85\u52a9\u8bf4\u660e<\/p>\n<\/li>\n<li>\n<p>\u2013version : \u663e\u793a\u7248\u672c<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6743\u9650\u7684\u8bbe\u5b9a\u65b9\u6cd5\u6709\u4e24\u79cd\uff0c \u5206\u522b\u53ef\u4ee5\u4f7f\u7528\u6570\u5b57\u6216\u8005\u662f\u7b26\u53f7\u6765\u8fdb\u884c\u6743\u9650\u7684\u53d8\u66f4\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u6570\u5b57\u7c7b\u578b\u6539\u53d8\u6863\u6848\u6743\u9650\uff1a<\/strong><\/p>\n<p style=\"margin-bottom: 0em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/cdbea8413fad419de056bdc6e5eeb325-6.png\" class=\"aligncenter\" title=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe6\" alt=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe6\" \/><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u7b26\u53f7\u7c7b\u578b\u6539\u53d8\u6863\u6848\u6743\u9650\uff1a<\/strong><\/p>\n<p style=\"margin-bottom: 0em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/d062e01afa05c69a979ff1453ad80bf4-7.png\" class=\"aligncenter\" title=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe7\" alt=\"Linux\u547d\u4ee4\u5927\u5168\u63d2\u56fe7\" \/><\/p>\n<h1>\u56db\u3001\u538b\u7f29\u6587\u4ef6\u64cd\u4f5c<\/h1>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Linux \u5e38\u7528\u7684\u538b\u7f29\u4e0e\u89e3\u538b\u7f29\u547d\u4ee4\u6709\uff1atar\u3001gzip\u3001gunzip\u3001bzip2\u3001bunzip2\u3001compress \u3001uncompress\u3001 zip\u3001 unzip\u3001rar\u3001unrar \u7b49\u3002<\/p>\n<h2>4.1 \u6253\u5305\u548c\u538b\u7f29\u548c\u89e3\u538b<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Windows\u7684\u538b\u7f29\u6587\u4ef6\u7684\u6269\u5c55\u540d .zip\/.rarlinux\u4e2d\u7684\u6253\u5305\u6587\u4ef6\uff1aaa.tarlinux\u4e2d\u7684\u538b\u7f29\u6587\u4ef6\uff1abb.gzlinux\u4e2d\u6253\u5305\u5e76\u538b\u7f29\u7684\u6587\u4ef6\uff1a.tar.gz<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Linux\u4e2d\u7684\u6253\u5305\u6587\u4ef6\u4e00\u822c\u662f\u4ee5.tar\u7ed3\u5c3e\u7684\uff0c\u538b\u7f29\u7684\u547d\u4ee4\u4e00\u822c\u662f\u4ee5.gz\u7ed3\u5c3e\u7684\u3002\u800c\u4e00\u822c\u60c5\u51b5\u4e0b\u6253\u5305\u548c\u538b\u7f29\u662f\u4e00\u8d77\u8fdb\u884c\u7684\uff0c\u6253\u5305\u5e76\u538b\u7f29\u540e\u7684\u6587\u4ef6\u7684\u540e\u7f00\u540d\u4e00\u822c.tar.gz\u3002<\/p>\n<h3>4.1.1 tar<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6700\u5e38\u7528\u7684\u6253\u5305\u547d\u4ee4\u662f tar\uff0c\u4f7f\u7528 tar \u7a0b\u5e8f\u6253\u51fa\u6765\u7684\u5305\u6211\u4eec\u5e38\u79f0\u4e3a tar \u5305\uff0ctar \u5305\u6587\u4ef6\u7684\u547d\u4ee4\u901a\u5e38\u90fd\u662f\u4ee5 .tar \u7ed3\u5c3e\u7684\u3002\u751f\u6210 tar \u5305\u540e\uff0c\u5c31\u53ef\u4ee5\u7528\u5176\u5b83\u7684\u7a0b\u5e8f\u6765\u8fdb\u884c\u538b\u7f29\u4e86\uff0c\u6240\u4ee5\u9996\u5148\u5c31\u6765\u8bb2\u8bb2 tar \u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">tar \u547d\u4ee4\u7684\u9009\u9879\u6709\u5f88\u591a(\u7528 man tar \u53ef\u4ee5\u67e5\u770b\u5230)\uff0c\u4f46\u5e38\u7528\u7684\u5c31\u90a3\u4e48\u51e0\u4e2a\u9009\u9879\uff0c\u4e0b\u9762\u6765\u4e3e\u4f8b\u8bf4\u660e\u4e00\u4e0b\uff1a<\/p>\n<pre>&nbsp;tar&nbsp;-cf&nbsp;all.tar&nbsp;*.jpg<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .jpg \u7684\u6587\u4ef6\u6253\u6210\u4e00\u4e2a\u540d\u4e3a all.tar \u7684\u5305\u3002-c \u662f\u8868\u793a\u4ea7\u751f\u65b0\u7684\u5305\uff0c-f \u6307\u5b9a\u5305\u7684\u6587\u4ef6\u540d\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-rf&nbsp;all.tar&nbsp;*.gif<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .gif \u7684\u6587\u4ef6\u589e\u52a0\u5230 all.tar \u7684\u5305\u91cc\u9762\u53bb\uff0c-r \u662f\u8868\u793a\u589e\u52a0\u6587\u4ef6\u7684\u610f\u601d\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-uf&nbsp;all.tar&nbsp;logo.gif<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u66f4\u65b0\u539f\u6765 tar \u5305 all.tar \u4e2d logo.gif \u6587\u4ef6\uff0c-u \u662f\u8868\u793a\u66f4\u65b0\u6587\u4ef6\u7684\u610f\u601d\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-tf&nbsp;all.tar<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5217\u51fa all.tar \u5305\u4e2d\u6240\u6709\u6587\u4ef6\uff0c-t \u662f\u5217\u51fa\u6587\u4ef6\u7684\u610f\u601d\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-xf&nbsp;all.tar<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u89e3\u51fa all.tar \u5305\u4e2d\u6240\u6709\u6587\u4ef6\uff0c-x \u662f\u89e3\u5f00\u7684\u610f\u601d\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4ee5\u4e0a\u5c31\u662f tar \u7684\u6700\u57fa\u672c\u7684\u7528\u6cd5\u3002\u4e3a\u4e86\u65b9\u4fbf\u7528\u6237\u5728\u6253\u5305\u89e3\u5305\u7684\u540c\u65f6\u53ef\u4ee5\u538b\u7f29\u6216\u89e3\u538b\u6587\u4ef6\uff0ctar \u63d0\u4f9b\u4e86\u4e00\u79cd\u7279\u6b8a\u7684\u529f\u80fd\u3002\u8fd9\u5c31\u662f tar \u53ef\u4ee5\u5728\u6253\u5305\u6216\u89e3\u5305\u7684\u540c\u65f6\u8c03\u7528\u5176\u5b83\u7684\u538b\u7f29\u7a0b\u5e8f\uff0c\u6bd4\u5982\u8c03\u7528 gzip\u3001bzip2 \u7b49\u3002<\/p>\n<h4>4.1.1.1 tar\u8c03\u7528<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">gzip \u662f GNU \u7ec4\u7ec7\u5f00\u53d1\u7684\u4e00\u4e2a\u538b\u7f29\u7a0b\u5e8f\uff0c.gz \u7ed3\u5c3e\u7684\u6587\u4ef6\u5c31\u662f gzip \u538b\u7f29\u7684\u7ed3\u679c\u3002\u4e0e gzip \u76f8\u5bf9\u7684\u89e3\u538b\u7a0b\u5e8f\u662f gunzip\u3002tar \u4e2d\u4f7f\u7528 -z \u8fd9\u4e2a\u53c2\u6570\u6765\u8c03\u7528gzip\u3002\u4e0b\u9762\u6765\u4e3e\u4f8b\u8bf4\u660e\u4e00\u4e0b\uff1a<\/p>\n<pre>&nbsp;tar&nbsp;-czf&nbsp;all.tar.gz&nbsp;*.jpg<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .jpg \u7684\u6587\u4ef6\u6253\u6210\u4e00\u4e2a tar \u5305\uff0c\u5e76\u4e14\u5c06\u5176\u7528 gzip \u538b\u7f29\uff0c\u751f\u6210\u4e00\u4e2a gzip \u538b\u7f29\u8fc7\u7684\u5305\uff0c\u5305\u540d\u4e3a all.tar.gz\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-xzf&nbsp;all.tar.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u4e0a\u9762\u4ea7\u751f\u7684\u5305\u89e3\u5f00\u3002<\/p>\n<h4>4.1.1.2 &nbsp;tar \u8c03\u7528 bzip2<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">bzip2 \u662f\u4e00\u4e2a\u538b\u7f29\u80fd\u529b\u66f4\u5f3a\u7684\u538b\u7f29\u7a0b\u5e8f\uff0c.bz2 \u7ed3\u5c3e\u7684\u6587\u4ef6\u5c31\u662f bzip2 \u538b\u7f29\u7684\u7ed3\u679c\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e0e bzip2 \u76f8\u5bf9\u7684\u89e3\u538b\u7a0b\u5e8f\u662f bunzip2\u3002tar \u4e2d\u4f7f\u7528 -j \u8fd9\u4e2a\u53c2\u6570\u6765\u8c03\u7528 gzip\u3002\u4e0b\u9762\u6765\u4e3e\u4f8b\u8bf4\u660e\u4e00\u4e0b\uff1a<\/p>\n<pre>&nbsp;tar&nbsp;-cjf&nbsp;all.tar.bz2&nbsp;*.jpg<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .jpg \u7684\u6587\u4ef6\u6253\u6210\u4e00\u4e2a tar \u5305\uff0c\u5e76\u4e14\u5c06\u5176\u7528 bzip2 \u538b\u7f29\uff0c\u751f\u6210\u4e00\u4e2a bzip2 \u538b\u7f29\u8fc7\u7684\u5305\uff0c\u5305\u540d\u4e3a all.tar.bz2<\/p>\n<pre>&nbsp;tar&nbsp;-xjf&nbsp;all.tar.bz2<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u4e0a\u9762\u4ea7\u751f\u7684\u5305\u89e3\u5f00\u3002<\/p>\n<h4>4.1.1.3 tar \u8c03\u7528 compress<\/h4>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">compress \u4e5f\u662f\u4e00\u4e2a\u538b\u7f29\u7a0b\u5e8f\uff0c\u4f46\u662f\u597d\u8c61\u4f7f\u7528 compress \u7684\u4eba\u4e0d\u5982 gzip \u548c bzip2 \u7684\u4eba\u591a\u3002.Z \u7ed3\u5c3e\u7684\u6587\u4ef6\u5c31\u662f bzip2 \u538b\u7f29\u7684\u7ed3\u679c\u3002\u4e0e compress \u76f8\u5bf9\u7684\u89e3\u538b\u7a0b\u5e8f\u662f uncompress\u3002tar \u4e2d\u4f7f\u7528 -Z \u8fd9\u4e2a\u53c2\u6570\u6765\u8c03\u7528 compress\u3002\u4e0b\u9762\u6765\u4e3e\u4f8b\u8bf4\u660e\u4e00\u4e0b\uff1a<\/p>\n<pre>&nbsp;tar&nbsp;-cZf&nbsp;all.tar.Z&nbsp;*.jpg<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .jpg \u7684\u6587\u4ef6\u6253\u6210\u4e00\u4e2a tar \u5305\uff0c\u5e76\u4e14\u5c06\u5176\u7528 compress \u538b\u7f29\uff0c\u751f\u6210\u4e00\u4e2a uncompress \u538b\u7f29\u8fc7\u7684\u5305\uff0c\u5305\u540d\u4e3a all.tar.Z\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-xZf&nbsp;all.tar.Z<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u4e0a\u9762\u4ea7\u751f\u7684\u5305\u89e3\u5f00\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6709\u4e86\u4e0a\u9762\u7684\u77e5\u8bc6\uff0c\u4f60\u5e94\u8be5\u53ef\u4ee5\u89e3\u5f00\u591a\u79cd\u538b\u7f29\u6587\u4ef6\u4e86\uff0c\u4e0b\u9762\u5bf9\u4e8e tar \u7cfb\u5217\u7684\u538b\u7f29\u6587\u4ef6\u4f5c\u4e00\u4e2a\u5c0f\u7ed3\uff1a<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>1) \u5bf9\u4e8e.tar\u7ed3\u5c3e\u7684\u6587\u4ef6<\/strong><\/p>\n<pre>tar&nbsp;-xf&nbsp;all.tar<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>2) \u5bf9\u4e8e .gz \u7ed3\u5c3e\u7684\u6587\u4ef6<\/strong><\/p>\n<pre>gzip&nbsp;-d&nbsp;all.gzgunzip&nbsp;all.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>3)\u5bf9\u4e8e .tgz \u6216 .tar.gz \u7ed3\u5c3e\u7684\u6587\u4ef6<\/strong><\/p>\n<pre>tar&nbsp;-xzf&nbsp;all.tar.gztar&nbsp;-xzf&nbsp;all.tgz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>4) \u5bf9\u4e8e .bz2 \u7ed3\u5c3e\u7684\u6587\u4ef6<\/strong><\/p>\n<pre>bzip2&nbsp;-d&nbsp;all.bz2bunzip2&nbsp;all.bz2<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>5) \u5bf9\u4e8e tar.bz2 \u7ed3\u5c3e\u7684\u6587\u4ef6<\/strong><\/p>\n<pre>tar&nbsp;-xjf&nbsp;all.tar.bz2<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>6) \u5bf9\u4e8e .Z \u7ed3\u5c3e\u7684\u6587\u4ef6<\/strong><\/p>\n<pre>uncompress&nbsp;all.Z<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>7) \u5bf9\u4e8e .tar.Z \u7ed3\u5c3e\u7684\u6587\u4ef6<\/strong><\/p>\n<pre>tar&nbsp;-xZf&nbsp;all.tar.z<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53e6\u5916\u5bf9\u4e8e Windows \u4e0b\u7684\u5e38\u89c1\u538b\u7f29\u6587\u4ef6 .zip \u548c .rar\uff0cLinux \u4e5f\u6709\u76f8\u5e94\u7684\u65b9\u6cd5\u6765\u89e3\u538b\u5b83\u4eec\uff1a<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>1) \u5bf9\u4e8e .zip<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">linux \u4e0b\u63d0\u4f9b\u4e86 zip \u548c unzip \u7a0b\u5e8f\uff0czip \u662f\u538b\u7f29\u7a0b\u5e8f\uff0cunzip \u662f\u89e3\u538b\u7a0b\u5e8f\u3002\u5b83\u4eec\u7684\u53c2\u6570\u9009\u9879\u5f88\u591a\uff0c\u8fd9\u91cc\u53ea\u505a\u7b80\u5355\u4ecb\u7ecd\uff0c\u4f9d\u65e7\u4e3e\u4f8b\u8bf4\u660e\u4e00\u4e0b\u5176\u7528\u6cd5\uff1a<\/p>\n<pre>&nbsp;zip&nbsp;all.zip&nbsp;*.jpg<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .jpg \u7684\u6587\u4ef6\u538b\u7f29\u6210\u4e00\u4e2a zip \u5305:<\/p>\n<pre>&nbsp;unzip&nbsp;all.zip<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06 all.zip \u4e2d\u7684\u6240\u6709\u6587\u4ef6\u89e3\u538b\u51fa\u6765\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>2) \u5bf9\u4e8e .rar<\/strong><\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8981\u5728 linux \u4e0b\u5904\u7406 .rar \u6587\u4ef6\uff0c\u9700\u8981\u5b89\u88c5 RAR for Linux\u3002\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/www.rarsoft.com\/download.htm\uff0c\u4e0b\u8f7d\u540e\u5b89\u88c5\u5373\u53ef\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-xzpvf&nbsp;rarlinux-x64-5.6.b5.tar.gz&nbsp;cd&nbsp;rar&nbsp;&nbsp;make<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6837\u5c31\u5b89\u88c5\u597d\u4e86\uff0c\u5b89\u88c5\u540e\u5c31\u6709\u4e86 rar \u548c unrar \u8fd9\u4e24\u4e2a\u7a0b\u5e8f\uff0crar \u662f\u538b\u7f29\u7a0b\u5e8f\uff0cunrar \u662f\u89e3\u538b\u7a0b\u5e8f\u3002\u5b83\u4eec\u7684\u53c2\u6570\u9009\u9879\u5f88\u591a\uff0c\u8fd9\u91cc\u53ea\u505a\u7b80\u5355\u4ecb\u7ecd\uff0c\u4f9d\u65e7\u4e3e\u4f8b\u8bf4\u660e\u4e00\u4e0b\u5176\u7528\u6cd5\uff1a<\/p>\n<pre>&nbsp;rar&nbsp;a&nbsp;all&nbsp;*.jpg<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .jpg \u7684\u6587\u4ef6\u538b\u7f29\u6210\u4e00\u4e2a rar \u5305\uff0c\u540d\u4e3a all.rar\uff0c\u8be5\u7a0b\u5e8f\u4f1a\u5c06 .rar \u6269\u5c55\u540d\u5c06\u81ea\u52a8\u9644\u52a0\u5230\u5305\u540d\u540e\u3002<\/p>\n<pre>&nbsp;unrar&nbsp;e&nbsp;all.rar<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06 all.rar \u4e2d\u7684\u6240\u6709\u6587\u4ef6\u89e3\u538b\u51fa\u6765<\/p>\n<h2>4.2 \u6269\u5c55\u5185\u5bb9<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>tar<\/strong><\/p>\n<pre>-c:&nbsp;\u5efa\u7acb\u538b\u7f29\u6863\u6848&nbsp;-x\uff1a\u89e3\u538b&nbsp;-t\uff1a\u67e5\u770b\u5185\u5bb9&nbsp;shell-r\uff1a\u5411\u538b\u7f29\u5f52\u6863\u6587\u4ef6\u672b\u5c3e\u8ffd\u52a0\u6587\u4ef6&nbsp;-u\uff1a\u66f4\u65b0\u539f\u538b\u7f29\u5305\u4e2d\u7684\u6587\u4ef6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u4e94\u4e2a\u662f\u72ec\u7acb\u7684\u547d\u4ee4\uff0c\u538b\u7f29\u89e3\u538b\u90fd\u8981\u7528\u5230\u5176\u4e2d\u4e00\u4e2a\uff0c\u53ef\u4ee5\u548c\u522b\u7684\u547d\u4ee4\u8fde\u7528\u4f46\u53ea\u80fd\u7528\u5176\u4e2d\u4e00\u4e2a\u3002\u4e0b\u9762\u7684\u53c2\u6570\u662f\u6839\u636e\u9700\u8981\u5728\u538b\u7f29\u6216\u89e3\u538b\u6863\u6848\u65f6\u53ef\u9009\u7684\u3002<\/p>\n<pre>-z\uff1a\u6709gzip\u5c5e\u6027\u7684&nbsp;-j\uff1a\u6709bz2\u5c5e\u6027\u7684&nbsp;-Z\uff1a\u6709compress\u5c5e\u6027\u7684&nbsp;-v\uff1a\u663e\u793a\u6240\u6709\u8fc7\u7a0b&nbsp;-O\uff1a\u5c06\u6587\u4ef6\u89e3\u5f00\u5230\u6807\u51c6\u8f93\u51fa<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e0b\u9762\u7684\u53c2\u6570 -f \u662f\u5fc5\u987b\u7684:<\/p>\n<pre>-f:&nbsp;\u4f7f\u7528\u6863\u6848\u540d\u5b57\uff0c\u5207\u8bb0\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u6700\u540e\u4e00\u4e2a\u53c2\u6570\uff0c\u540e\u9762\u53ea\u80fd\u63a5\u6863\u6848\u540d\u3002<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"># tar -cf all.tar *.jpg<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .jpg \u7684\u6587\u4ef6\u6253\u6210\u4e00\u4e2a\u540d\u4e3a all.tar \u7684\u5305\u3002-c \u662f\u8868\u793a\u4ea7\u751f\u65b0\u7684\u5305\uff0c-f \u6307\u5b9a\u5305\u7684\u6587\u4ef6\u540d\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-rf&nbsp;all.tar&nbsp;*.gif<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5c06\u6240\u6709 .gif \u7684\u6587\u4ef6\u589e\u52a0\u5230 all.tar \u7684\u5305\u91cc\u9762\u53bb\u3002-r \u662f\u8868\u793a\u589e\u52a0\u6587\u4ef6\u7684\u610f\u601d\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-uf&nbsp;all.tar&nbsp;logo.gif<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u66f4\u65b0\u539f\u6765 tar \u5305 all.tar \u4e2d logo.gif \u6587\u4ef6\uff0c-u \u662f\u8868\u793a\u66f4\u65b0\u6587\u4ef6\u7684\u610f\u601d\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-tf&nbsp;all.tar<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u5217\u51fa all.tar \u5305\u4e2d\u6240\u6709\u6587\u4ef6\uff0c-t \u662f\u5217\u51fa\u6587\u4ef6\u7684\u610f\u601d\u3002<\/p>\n<pre>&nbsp;tar&nbsp;-xf&nbsp;all.tar<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd9\u6761\u547d\u4ee4\u662f\u89e3\u51fa all.tar \u5305\u4e2d\u6240\u6709\u6587\u4ef6\uff0c-x \u662f\u89e3\u5f00\u7684\u610f\u601d\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u538b\u7f29<\/strong><\/p>\n<pre>tar&nbsp;\u2013cvf&nbsp;jpg.tar&nbsp;*.jpg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u5c06\u76ee\u5f55\u91cc\u6240\u6709jpg\u6587\u4ef6\u6253\u5305\u6210&nbsp;tar.jpg&nbsp;tar&nbsp;\u2013czf&nbsp;jpg.tar.gz&nbsp;*.jpg&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u5c06\u76ee\u5f55\u91cc\u6240\u6709jpg\u6587\u4ef6\u6253\u5305\u6210&nbsp;jpg.tar&nbsp;\u540e\uff0c\u5e76\u4e14\u5c06\u5176\u7528&nbsp;gzip&nbsp;\u538b\u7f29\uff0c\u751f\u6210\u4e00\u4e2a&nbsp;gzip&nbsp;\u538b\u7f29\u8fc7\u7684\u5305\uff0c\u547d\u540d\u4e3a&nbsp;jpg.tar.gz&nbsp;tar&nbsp;\u2013cjf&nbsp;jpg.tar.bz2&nbsp;*.jpg&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u5c06\u76ee\u5f55\u91cc\u6240\u6709jpg\u6587\u4ef6\u6253\u5305\u6210&nbsp;jpg.tar&nbsp;\u540e\uff0c\u5e76\u4e14\u5c06\u5176\u7528&nbsp;bzip2&nbsp;\u538b\u7f29\uff0c\u751f\u6210\u4e00\u4e2a&nbsp;bzip2&nbsp;\u538b\u7f29\u8fc7\u7684\u5305\uff0c\u547d\u540d\u4e3ajpg.tar.bz2&nbsp;tar&nbsp;\u2013cZf&nbsp;jpg.tar.Z&nbsp;*.jpg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u5c06\u76ee\u5f55\u91cc\u6240\u6709&nbsp;jpg&nbsp;\u6587\u4ef6\u6253\u5305\u6210&nbsp;jpg.tar&nbsp;\u540e\uff0c\u5e76\u4e14\u5c06\u5176\u7528&nbsp;compress&nbsp;\u538b\u7f29\uff0c\u751f\u6210\u4e00\u4e2a&nbsp;umcompress&nbsp;\u538b\u7f29\u8fc7\u7684\u5305\uff0c\u547d\u540d\u4e3ajpg.tar.Z&nbsp;rar&nbsp;a&nbsp;jpg.rar&nbsp;*.jpg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;rar\u683c\u5f0f\u7684\u538b\u7f29\uff0c\u9700\u8981\u5148\u4e0b\u8f7d&nbsp;rar&nbsp;for&nbsp;linux&nbsp;zip&nbsp;jpg.zip&nbsp;*.jpg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;zip\u683c\u5f0f\u7684\u538b\u7f29\uff0c\u9700\u8981\u5148\u4e0b\u8f7d&nbsp;zip&nbsp;for&nbsp;linux<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u89e3\u538b<\/strong><\/p>\n<pre>tar&nbsp;\u2013xvf&nbsp;file.tar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u89e3\u538b&nbsp;tar&nbsp;\u5305&nbsp;tar&nbsp;-xzvf&nbsp;file.tar.gz&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u89e3\u538b&nbsp;tar.gz&nbsp;tar&nbsp;-xjvf&nbsp;file.tar.bz2&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u89e3\u538b&nbsp;tar.bz2&nbsp;tar&nbsp;\u2013xZvf&nbsp;file.tar.Z&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u89e3\u538b&nbsp;tar.Z&nbsp;unrar&nbsp;e&nbsp;file.rar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u89e3\u538b&nbsp;rar&nbsp;unzip&nbsp;file.zip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u89e3\u538b&nbsp;zip<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u603b\u7ed3<\/strong><\/p>\n<pre>1\u3001*.tar&nbsp;\u7528&nbsp;tar&nbsp;\u2013xvf&nbsp;\u89e3\u538b&nbsp;2\u3001*.gz&nbsp;\u7528&nbsp;gzip&nbsp;-d\u6216\u8005gunzip&nbsp;\u89e3\u538b&nbsp;3\u3001*.tar.gz\u548c*.tgz&nbsp;\u7528&nbsp;tar&nbsp;\u2013xzf&nbsp;\u89e3\u538b&nbsp;4\u3001*.bz2&nbsp;\u7528&nbsp;bzip2&nbsp;-d\u6216\u8005\u7528bunzip2&nbsp;\u89e3\u538b&nbsp;5\u3001*.tar.bz2\u7528tar&nbsp;\u2013xjf&nbsp;\u89e3\u538b&nbsp;6\u3001*.Z&nbsp;\u7528&nbsp;uncompress&nbsp;\u89e3\u538b&nbsp;7\u3001*.tar.Z&nbsp;\u7528tar&nbsp;\u2013xZf&nbsp;\u89e3\u538b&nbsp;8\u3001*.rar&nbsp;\u7528&nbsp;unrar&nbsp;e\u89e3\u538b&nbsp;9\u3001*.zip&nbsp;\u7528&nbsp;unzip&nbsp;\u89e3\u538b<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h1>\u4e94\u3001\u67e5\u627e\u547d\u4ee4<\/h1>\n<h2>5.1 grep<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">grep\u547d\u4ee4\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u6587\u672c\u641c\u7d22\u5de5\u5177<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<pre>ps&nbsp;-ef&nbsp;|&nbsp;grep&nbsp;sshd&nbsp;&nbsp;\u67e5\u627e\u6307\u5b9assh\u670d\u52a1\u8fdb\u7a0b&nbsp;ps&nbsp;-ef&nbsp;|&nbsp;grep&nbsp;sshd&nbsp;|&nbsp;grep&nbsp;-v&nbsp;grep&nbsp;\u67e5\u627e\u6307\u5b9a\u670d\u52a1\u8fdb\u7a0b\uff0c\u6392\u9664gerp\u8eab&nbsp;ps&nbsp;-ef&nbsp;|&nbsp;grep&nbsp;sshd&nbsp;-c&nbsp;\u67e5\u627e\u6307\u5b9a\u8fdb\u7a0b\u4e2a\u6570<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u4ece\u6587\u4ef6\u5185\u5bb9\u67e5\u627e\u5339\u914d\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u884c\uff1a<\/strong><\/p>\n<pre>$&nbsp;grep&nbsp;\"\u88ab\u67e5\u627e\u7684\u5b57\u7b26\u4e32\"&nbsp;\u6587\u4ef6\u540d<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f8b\u5b50\uff1a\u5728\u5f53\u524d\u76ee\u5f55\u91cc\u7b2c\u4e00\u7ea7\u6587\u4ef6\u5939\u4e2d\u5bfb\u627e\u5305\u542b\u6307\u5b9a\u5b57\u7b26\u4e32\u7684 .in \u6587\u4ef6<\/p>\n<pre>grep&nbsp;\"thermcontact\"&nbsp;\/.in<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4ece\u6587\u4ef6\u5185\u5bb9\u67e5\u627e\u4e0e\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u7684\u884c\uff1a<\/p>\n<pre>$&nbsp;grep&nbsp;\u2013e&nbsp;\"\u6b63\u5219\u8868\u8fbe\u5f0f\"&nbsp;\u6587\u4ef6\u540d<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u67e5\u627e\u65f6\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff1a<\/p>\n<pre>$&nbsp;grep&nbsp;\u2013i&nbsp;\"\u88ab\u67e5\u627e\u7684\u5b57\u7b26\u4e32\"&nbsp;\u6587\u4ef6\u540d<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u67e5\u627e\u5339\u914d\u7684\u884c\u6570\uff1a<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">$ grep -c \u201c\u88ab\u67e5\u627e\u7684\u5b57\u7b26\u4e32\u201d \u6587\u4ef6\u540d<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4ece\u6587\u4ef6\u5185\u5bb9\u67e5\u627e\u4e0d\u5339\u914d\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u884c\uff1a<\/p>\n<pre>$&nbsp;grep&nbsp;\u2013v&nbsp;\"\u88ab\u67e5\u627e\u7684\u5b57\u7b26\u4e32\"&nbsp;\u6587\u4ef6\u540d<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>5.2 find<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">find\u547d\u4ee4\u5728\u76ee\u5f55\u7ed3\u6784\u4e2d\u641c\u7d22\u6587\u4ef6\uff0c\u5e76\u5bf9\u641c\u7d22\u7ed3\u679c\u6267\u884c\u6307\u5b9a\u7684\u64cd\u4f5c\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">find \u9ed8\u8ba4\u641c\u7d22\u5f53\u524d\u76ee\u5f55\u53ca\u5176\u5b50\u76ee\u5f55\uff0c\u5e76\u4e14\u4e0d\u8fc7\u6ee4\u4efb\u4f55\u7ed3\u679c\uff08\u4e5f\u5c31\u662f\u8fd4\u56de\u6240\u6709\u6587\u4ef6\uff09\uff0c\u5c06\u5b83\u4eec\u5168\u90fd\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002\u53e6\u5916\uff0c\u641c\u7d22\u516c\u4f17\u53f7\u7f16\u7a0b\u6280\u672f\u5708\u540e\u53f0\u56de\u590d\u201c1024\u201d\uff0c\u83b7\u53d6\u4e00\u4efd\u60ca\u559c\u793c\u5305\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<pre>find&nbsp;.&nbsp;-name&nbsp;\"*.log\"&nbsp;-ls&nbsp;&nbsp;\u5728\u5f53\u524d\u76ee\u5f55\u67e5\u627e\u4ee5.log\u7ed3\u5c3e\u7684\u6587\u4ef6\uff0c\u5e76\u663e\u793a\u8be6\u7ec6\u4fe1\u606f\u3002find&nbsp;\/root\/&nbsp;-perm&nbsp;600&nbsp;&nbsp;&nbsp;\u67e5\u627e\/root\/\u76ee\u5f55\u4e0b\u6743\u9650\u4e3a600\u7684\u6587\u4ef6&nbsp;find&nbsp;.&nbsp;-type&nbsp;f&nbsp;-name&nbsp;\"*.log\"&nbsp;&nbsp;\u67e5\u627e\u5f53\u76ee\u5f55\uff0c\u4ee5.log\u7ed3\u5c3e\u7684\u666e\u901a\u6587\u4ef6&nbsp;find&nbsp;.&nbsp;-type&nbsp;d&nbsp;|&nbsp;sort&nbsp;&nbsp;&nbsp;\u67e5\u627e\u5f53\u524d\u6240\u6709\u76ee\u5f55\u5e76\u6392\u5e8f&nbsp;find&nbsp;.&nbsp;-size&nbsp;+100M&nbsp;&nbsp;\u67e5\u627e\u5f53\u524d\u76ee\u5f55\u5927\u4e8e100M\u7684\u6587\u4ef6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4ece\u6839\u76ee\u5f55\u5f00\u59cb\u67e5\u627e\u6240\u6709\u6269\u5c55\u540d\u4e3a .log \u7684\u6587\u672c\u6587\u4ef6\uff0c\u5e76\u627e\u51fa\u5305\u542b \u201cERROR\u201d \u7684\u884c\uff1a<\/p>\n<pre>$&nbsp;find&nbsp;\/&nbsp;-type&nbsp;f&nbsp;-name&nbsp;\"*.log\"&nbsp;|&nbsp;xargs&nbsp;grep&nbsp;\"ERROR\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f8b\u5b50\uff1a\u4ece\u5f53\u524d\u76ee\u5f55\u5f00\u59cb\u67e5\u627e\u6240\u6709\u6269\u5c55\u540d\u4e3a .in \u7684\u6587\u672c\u6587\u4ef6\uff0c\u5e76\u627e\u51fa\u5305\u542b \u201cthermcontact\u201d \u7684\u884c\uff1a<\/p>\n<pre>find&nbsp;.&nbsp;-name&nbsp;\"*.in\"&nbsp;|&nbsp;xargs&nbsp;grep&nbsp;\"thermcontact\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>5.3 locate<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">locate \u8ba9\u4f7f\u7528\u8005\u53ef\u4ee5\u5f88\u5feb\u901f\u7684\u641c\u5bfb\u67d0\u4e2a\u8def\u5f84\u3002\u9ed8\u8ba4\u6bcf\u5929\u81ea\u52a8\u66f4\u65b0\u4e00\u6b21\uff0c\u6240\u4ee5\u4f7f\u7528locate \u547d\u4ee4\u67e5\u4e0d\u5230\u6700\u65b0\u53d8\u52a8\u8fc7\u7684\u6587\u4ef6\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728\u4f7f\u7528locate\u4e4b\u524d\uff0c\u5148\u4f7f\u7528updatedb\u547d\u4ee4\uff0c\u624b\u52a8\u66f4\u65b0\u6570\u636e\u5e93\u3002\u5982\u679c\u6570\u636e\u5e93\u4e2d\u6ca1\u6709\u67e5\u8be2\u7684\u6570\u636e\uff0c\u5219\u4f1a\u62a5\u51falocate: can not stat () `\/var\/lib\/mlocate\/mlocate.db\u2019: No such file or directory\u8be5\u9519\u8bef\uff01updatedb\u5373\u53ef\uff01<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">yum -y install mlocate \u5982\u679c\u662f\u7cbe\u7b80\u7248CentOS\u7cfb\u7edf\u9700\u8981\u5b89\u88c5locate\u547d\u4ee4<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<pre>updatedblocate&nbsp;\/etc\/sh&nbsp;\u641c\u7d22etc\u76ee\u5f55\u4e0b\u6240\u6709\u4ee5sh\u5f00\u5934\u7684\u6587\u4ef6&nbsp;locate&nbsp;pwd&nbsp;\u67e5\u627e\u548cpwd\u76f8\u5173\u7684\u6240\u6709\u6587\u4ef6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>5.4 whereis<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">whereis\u547d\u4ee4\u662f\u5b9a\u4f4d\u53ef\u6267\u884c\u6587\u4ef6\u3001\u6e90\u4ee3\u7801\u6587\u4ef6\u3001\u5e2e\u52a9\u6587\u4ef6\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u4f4d\u7f6e\u3002\u8fd9\u4e9b\u6587\u4ef6\u7684\u5c5e\u6027\u5e94\u5c5e\u4e8e\u539f\u59cb\u4ee3\u7801\uff0c\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u6216\u662f\u5e2e\u52a9\u6587\u4ef6\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<pre>whereis&nbsp;ls&nbsp;&nbsp;&nbsp;&nbsp;\u5c06\u548cls\u6587\u4ef6\u76f8\u5173\u7684\u6587\u4ef6\u90fd\u67e5\u627e\u51fa\u6765<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>5.5 which<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">which\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u5728PATH\u53d8\u91cf\u6307\u5b9a\u7684\u8def\u5f84\u4e2d\uff0c\u641c\u7d22\u67d0\u4e2a\u7cfb\u7edf\u547d\u4ee4\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e14\u8fd4\u56de\u7b2c\u4e00\u4e2a\u641c\u7d22\u7ed3\u679c\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528\u5b9e\u4f8b\uff1a<\/p>\n<pre>which&nbsp;pwd&nbsp;&nbsp;\u67e5\u627epwd\u547d\u4ee4\u6240\u5728\u8def\u5f84&nbsp;which&nbsp;java&nbsp;&nbsp;\u67e5\u627epath\u4e2djava\u7684\u8def\u5f84<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h1>\u516d\u3001su\u3001sudo<\/h1>\n<h2>6.1 su<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Linux su\u547d\u4ee4\u7528\u4e8e\u53d8\u66f4\u4e3a\u5176\u4ed6\u4f7f\u7528\u8005\u7684\u8eab\u4efd\uff0c\u9664 root \u5916\uff0c\u9700\u8981\u952e\u5165\u8be5\u4f7f\u7528\u8005\u7684\u5bc6\u7801\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528\u6743\u9650\uff1a\u6240\u6709\u4f7f\u7528\u8005\u3002<\/p>\n<h3>\u8bed\u6cd5<\/h3>\n<pre>su&nbsp;[-fmp]&nbsp;[-c&nbsp;command]&nbsp;[-s&nbsp;shell]&nbsp;[--help]&nbsp;[--version]&nbsp;[-]&nbsp;[USER&nbsp;[ARG]]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u53c2\u6570\u8bf4\u660e<\/strong>\uff1a<\/p>\n<ul>\n<li>\n<p>-f \u6216 \u2014fast \u4e0d\u5fc5\u8bfb\u542f\u52a8\u6863\uff08\u5982 csh.cshrc \u7b49\uff09\uff0c\u4ec5\u7528\u4e8e csh \u6216 tcsh<\/p>\n<\/li>\n<li>\n<p>-m -p \u6216 \u2014preserve-environment \u6267\u884c su \u65f6\u4e0d\u6539\u53d8\u73af\u5883\u53d8\u6570<\/p>\n<\/li>\n<li>\n<p>-c command \u6216 \u2014command=command \u53d8\u66f4\u4e3a\u5e10\u53f7\u4e3a USER \u7684\u4f7f\u7528\u8005\u5e76\u6267\u884c\u6307\u4ee4\uff08command\uff09\u540e\u518d\u53d8\u56de\u539f\u6765\u4f7f\u7528\u8005<\/p>\n<\/li>\n<li>\n<p>-s shell \u6216 \u2014shell=shell \u6307\u5b9a\u8981\u6267\u884c\u7684 shell \uff08bash csh tcsh \u7b49\uff09\uff0c\u9884\u8bbe\u503c\u4e3a \/etc\/passwd \u5185\u7684\u8be5\u4f7f\u7528\u8005\uff08USER\uff09 shell<\/p>\n<\/li>\n<li>\n<p>\u2013help \u663e\u793a\u8bf4\u660e\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u2013version \u663e\u793a\u7248\u672c\u8d44\u8baf<\/p>\n<\/li>\n<li>\n<p>&#8211; -l \u6216 \u2014login \u8fd9\u4e2a\u53c2\u6570\u52a0\u4e86\u4e4b\u540e\uff0c\u5c31\u597d\u50cf\u662f\u91cd\u65b0 login \u4e3a\u8be5\u4f7f\u7528\u8005\u4e00\u6837\uff0c\u5927\u90e8\u4efd\u73af\u5883\u53d8\u6570\uff08HOME SHELL USER\u7b49\u7b49\uff09\u90fd\u662f\u4ee5\u8be5\u4f7f\u7528\u8005\uff08USER\uff09\u4e3a\u4e3b\uff0c\u5e76\u4e14\u5de5\u4f5c\u76ee\u5f55\u4e5f\u4f1a\u6539\u53d8\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a USER \uff0c\u5185\u5b9a\u662f root<\/p>\n<\/li>\n<li>\n<p>USER \u6b32\u53d8\u66f4\u7684\u4f7f\u7528\u8005\u5e10\u53f7<\/p>\n<\/li>\n<li>\n<p>ARG \u4f20\u5165\u65b0\u7684 shell \u53c2\u6570<\/p>\n<\/li>\n<\/ul>\n<h3>\u5b9e\u4f8b<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53d8\u66f4\u5e10\u53f7\u4e3a root \u5e76\u5728\u6267\u884c ls \u6307\u4ee4\u540e\u9000\u51fa\u53d8\u56de\u539f\u4f7f\u7528\u8005<\/p>\n<pre>su&nbsp;-c&nbsp;ls&nbsp;root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53d8\u66f4\u5e10\u53f7\u4e3a root \u5e76\u4f20\u5165 -f \u53c2\u6570\u7ed9\u65b0\u6267\u884c\u7684 shell<\/p>\n<pre>su&nbsp;root&nbsp;-f<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53d8\u66f4\u5e10\u53f7\u4e3a clsung \u5e76\u6539\u53d8\u5de5\u4f5c\u76ee\u5f55\u81f3 clsung \u7684\u5bb6\u76ee\u5f55\uff08home dir\uff09<\/p>\n<pre>su&nbsp;-&nbsp;clsung<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5207\u6362\u7528\u6237<\/p>\n<pre>hnlinux@runoob.com:~$&nbsp;whoami&nbsp;\/\/\u663e\u793a\u5f53\u524d\u7528\u6237hnlinuxhnlinux@runoob.com:~$&nbsp;pwd&nbsp;\/\/\u663e\u793a\u5f53\u524d\u76ee\u5f55\/home\/hnlinuxhnlinux@runoob.com:~$&nbsp;su&nbsp;root&nbsp;\/\/\u5207\u6362\u5230root\u7528\u6237\u5bc6\u7801\uff1aroot@runoob.com:\/home\/hnlinux#&nbsp;whoami&nbsp;rootroot@runoob.com:\/home\/hnlinux#&nbsp;pwd\/home\/hnlinux<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5207\u6362\u7528\u6237\uff0c\u6539\u53d8\u73af\u5883\u53d8\u91cf<\/p>\n<pre>hnlinux@runoob.com:~$&nbsp;whoami&nbsp;\/\/\u663e\u793a\u5f53\u524d\u7528\u6237hnlinuxhnlinux@runoob.com:~$&nbsp;pwd&nbsp;\/\/\u663e\u793a\u5f53\u524d\u76ee\u5f55\/home\/hnlinuxhnlinux@runoob.com:~$&nbsp;su&nbsp;-&nbsp;root&nbsp;\/\/\u5207\u6362\u5230root\u7528\u6237\u5bc6\u7801\uff1aroot@runoob.com:\/home\/hnlinux#&nbsp;whoami&nbsp;rootroot@runoob.com:\/home\/hnlinux#&nbsp;pwd&nbsp;\/\/\u663e\u793a\u5f53\u524d\u76ee\u5f55\/root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">su\u7528\u4e8e\u7528\u6237\u4e4b\u95f4\u7684\u5207\u6362\u3002\u4f46\u662f\u5207\u6362\u524d\u7684\u7528\u6237\u4f9d\u7136\u4fdd\u6301\u767b\u5f55\u72b6\u6001\u3002\u5982\u679c\u662froot \u5411\u666e\u901a\u6216\u865a\u62df\u7528\u6237\u5207\u6362\u4e0d\u9700\u8981\u5bc6\u7801\uff0c\u53cd\u4e4b\u666e\u901a\u7528\u6237\u5207\u6362\u5230\u5176\u5b83\u4efb\u4f55\u7528\u6237\u90fd\u9700\u8981\u5bc6\u7801\u9a8c\u8bc1\u3002<\/p>\n<pre>su&nbsp;test:\u5207\u6362\u5230test\u7528\u6237\uff0c\u4f46\u662f\u8def\u5f84\u8fd8\u662f\/root\u76ee\u5f55su&nbsp;-&nbsp;test&nbsp;:&nbsp;\u5207\u6362\u5230test\u7528\u6237\uff0c\u8def\u5f84\u53d8\u6210\u4e86\/home\/testsu&nbsp;:&nbsp;\u5207\u6362\u5230root\u7528\u6237\uff0c\u4f46\u662f\u8def\u5f84\u8fd8\u662f\u539f\u6765\u7684\u8def\u5f84su&nbsp;-&nbsp;:&nbsp;\u5207\u6362\u5230root\u7528\u6237\uff0c\u5e76\u4e14\u8def\u5f84\u662f\/rootsu\u4e0d\u8db3\uff1a\u5982\u679c\u67d0\u4e2a\u7528\u6237\u9700\u8981\u4f7f\u7528root\u6743\u9650\u3001\u5219\u5fc5\u987b\u8981\u628aroot\u5bc6\u7801\u544a\u8bc9\u6b64\u7528\u6237\u3002\u9000\u51fa\u8fd4\u56de\u4e4b\u524d\u7684\u7528\u6237\uff1aexit<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>6.2 sudo<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">sudo\u662f\u4e3a\u6240\u6709\u60f3\u4f7f\u7528root\u6743\u9650\u7684\u666e\u901a\u7528\u6237\u8bbe\u8ba1\u7684\u3002\u53ef\u4ee5\u8ba9\u666e\u901a\u7528\u6237\u5177\u6709\u4e34\u65f6\u4f7f\u7528root\u6743\u9650\u7684\u6743\u5229\u3002\u53ea\u9700\u8f93\u5165\u81ea\u5df1\u8d26\u6237\u7684\u5bc6\u7801\u5373\u53ef\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fdb\u5165sudo\u914d\u7f6e\u6587\u4ef6\u547d\u4ee4\uff1a<\/p>\n<pre>vi&nbsp;\/etc\/sudoer\u6216\u8005visudo<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6848\u4f8b\uff1a\u5141\u8bb8hadoop\u7528\u6237\u4ee5root\u8eab\u4efd\u6267\u884c\u5404\u79cd\u5e94\u7528\u547d\u4ee4\uff0c\u9700\u8981\u8f93\u5165hadoop\u7528\u6237\u7684\u5bc6\u7801\u3002hadoop ALL=(ALL) ALL<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6848\u4f8b\uff1a\u53ea\u5141\u8bb8hadoop\u7528\u6237\u4ee5root\u8eab\u4efd\u6267\u884cls \u3001cat\u547d\u4ee4\uff0c\u5e76\u4e14\u6267\u884c\u65f6\u5019\u514d\u8f93\u5165\u5bc6\u7801\u3002\u914d\u7f6e\u6587\u4ef6\u4e2d\uff1ahadoop ALL=NOPASSWD: \/bin\/ls, \/bin\/cat<\/p>\n<pre>su&nbsp;root&nbsp;-f<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53d8\u66f4\u5e10\u53f7\u4e3a clsung \u5e76\u6539\u53d8\u5de5\u4f5c\u76ee\u5f55\u81f3 clsung \u7684\u5bb6\u76ee\u5f55\uff08home dir\uff09<\/p>\n<pre>su&nbsp;-&nbsp;clsung<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5207\u6362\u7528\u6237<\/p>\n<pre>hnlinux@runoob.com:~$&nbsp;whoami&nbsp;\/\/\u663e\u793a\u5f53\u524d\u7528\u6237hnlinuxhnlinux@runoob.com:~$&nbsp;pwd&nbsp;\/\/\u663e\u793a\u5f53\u524d\u76ee\u5f55\/home\/hnlinuxhnlinux@runoob.com:~$&nbsp;su&nbsp;root&nbsp;\/\/\u5207\u6362\u5230root\u7528\u6237\u5bc6\u7801\uff1aroot@runoob.com:\/home\/hnlinux#&nbsp;whoami&nbsp;rootroot@runoob.com:\/home\/hnlinux#&nbsp;pwd\/home\/hnlinux<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5207\u6362\u7528\u6237\uff0c\u6539\u53d8\u73af\u5883\u53d8\u91cf<\/p>\n<pre>hnlinux@runoob.com:~$&nbsp;whoami&nbsp;\/\/\u663e\u793a\u5f53\u524d\u7528\u6237hnlinuxhnlinux@runoob.com:~$&nbsp;pwd&nbsp;\/\/\u663e\u793a\u5f53\u524d\u76ee\u5f55\/home\/hnlinuxhnlinux@runoob.com:~$&nbsp;su&nbsp;-&nbsp;root&nbsp;\/\/\u5207\u6362\u5230root\u7528\u6237\u5bc6\u7801\uff1aroot@runoob.com:\/home\/hnlinux#&nbsp;whoami&nbsp;rootroot@runoob.com:\/home\/hnlinux#&nbsp;pwd&nbsp;\/\/\u663e\u793a\u5f53\u524d\u76ee\u5f55\/root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">su\u7528\u4e8e\u7528\u6237\u4e4b\u95f4\u7684\u5207\u6362\u3002\u4f46\u662f\u5207\u6362\u524d\u7684\u7528\u6237\u4f9d\u7136\u4fdd\u6301\u767b\u5f55\u72b6\u6001\u3002\u5982\u679c\u662froot \u5411\u666e\u901a\u6216\u865a\u62df\u7528\u6237\u5207\u6362\u4e0d\u9700\u8981\u5bc6\u7801\uff0c\u53cd\u4e4b\u666e\u901a\u7528\u6237\u5207\u6362\u5230\u5176\u5b83\u4efb\u4f55\u7528\u6237\u90fd\u9700\u8981\u5bc6\u7801\u9a8c\u8bc1\u3002<\/p>\n<pre>su&nbsp;test:\u5207\u6362\u5230test\u7528\u6237\uff0c\u4f46\u662f\u8def\u5f84\u8fd8\u662f\/root\u76ee\u5f55su&nbsp;-&nbsp;test&nbsp;:&nbsp;\u5207\u6362\u5230test\u7528\u6237\uff0c\u8def\u5f84\u53d8\u6210\u4e86\/home\/testsu&nbsp;:&nbsp;\u5207\u6362\u5230root\u7528\u6237\uff0c\u4f46\u662f\u8def\u5f84\u8fd8\u662f\u539f\u6765\u7684\u8def\u5f84su&nbsp;-&nbsp;:&nbsp;\u5207\u6362\u5230root\u7528\u6237\uff0c\u5e76\u4e14\u8def\u5f84\u662f\/rootsu\u4e0d\u8db3\uff1a\u5982\u679c\u67d0\u4e2a\u7528\u6237\u9700\u8981\u4f7f\u7528root\u6743\u9650\u3001\u5219\u5fc5\u987b\u8981\u628aroot\u5bc6\u7801\u544a\u8bc9\u6b64\u7528\u6237\u3002\u9000\u51fa\u8fd4\u56de\u4e4b\u524d\u7684\u7528\u6237\uff1aexit<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h1>\u4e03\u3001\u4e0b\u8f7d\u4e0e\u5b89\u88c5 yum<\/h1>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">yum\uff08 Yellow dog Updater, Modified\uff09\u662f\u4e00\u4e2a\u5728Fedora\u548cRedHat\u4ee5\u53caSUSE\u4e2d\u7684Shell\u524d\u7aef\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u57fa\u65bcRPM\u5305\u7ba1\u7406\uff0c\u80fd\u591f\u4ece\u6307\u5b9a\u7684\u670d\u52a1\u5668\u81ea\u52a8\u4e0b\u8f7dRPM\u5305\u5e76\u4e14\u5b89\u88c5\uff0c\u53ef\u4ee5\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u6027\u5173\u7cfb\uff0c\u5e76\u4e14\u4e00\u6b21\u5b89\u88c5\u6240\u6709\u4f9d\u8d56\u7684\u8f6f\u4f53\u5305\uff0c\u65e0\u987b\u7e41\u7410\u5730\u4e00\u6b21\u6b21\u4e0b\u8f7d\u3001\u5b89\u88c5\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">yum\u63d0\u4f9b\u4e86\u67e5\u627e\u3001\u5b89\u88c5\u3001\u5220\u9664\u67d0\u4e00\u4e2a\u3001\u4e00\u7ec4\u751a\u81f3\u5168\u90e8\u8f6f\u4ef6\u5305\u7684\u547d\u4ee4\uff0c\u800c\u4e14\u547d\u4ee4\u7b80\u6d01\u800c\u53c8\u597d\u8bb0\u3002<\/p>\n<h2>7.1 yum \u8bed\u6cd5<\/h2>\n<pre>yum&nbsp;[options]&nbsp;[command]&nbsp;[package&nbsp;...]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p><strong>options\uff1a<\/strong>\u53ef\u9009\uff0c\u9009\u9879\u5305\u62ec-h\uff08\u5e2e\u52a9\uff09\uff0c-y\uff08\u5f53\u5b89\u88c5\u8fc7\u7a0b\u63d0\u793a\u9009\u62e9\u5168\u90e8\u4e3a\u201dyes\u201d\uff09\uff0c-q\uff08\u4e0d\u663e\u793a\u5b89\u88c5\u7684\u8fc7\u7a0b\uff09\u7b49\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p><strong>command\uff1a<\/strong>\u8981\u8fdb\u884c\u7684\u64cd\u4f5c\u3002<\/p>\n<\/li>\n<li>\n<p><strong>package<\/strong>\u64cd\u4f5c\u7684\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<\/ul>\n<h2>7.2 yum\u5e38\u7528\u547d\u4ee4<\/h2>\n<ul>\n<li>\n<p>1.\u5217\u51fa\u6240\u6709\u53ef\u66f4\u65b0\u7684\u8f6f\u4ef6\u6e05\u5355\u547d\u4ee4\uff1ayum check-update<\/p>\n<\/li>\n<li>\n<p>2.\u66f4\u65b0\u6240\u6709\u8f6f\u4ef6\u547d\u4ee4\uff1ayum update<\/p>\n<\/li>\n<li>\n<p>3.\u4ec5\u5b89\u88c5\u6307\u5b9a\u7684\u8f6f\u4ef6\u547d\u4ee4\uff1ayum install<\/p>\n<\/li>\n<li>\n<p>4.\u4ec5\u66f4\u65b0\u6307\u5b9a\u7684\u8f6f\u4ef6\u547d\u4ee4\uff1ayum update<\/p>\n<\/li>\n<li>\n<p>5.\u5217\u51fa\u6240\u6709\u53ef\u5b89\u88dd\u7684\u8f6f\u4ef6\u6e05\u5355\u547d\u4ee4\uff1ayum list<\/p>\n<\/li>\n<li>\n<p>6.\u5220\u9664\u8f6f\u4ef6\u5305\u547d\u4ee4\uff1ayum remove<\/p>\n<\/li>\n<li>\n<p>7.\u67e5\u627e\u8f6f\u4ef6\u5305 \u547d\u4ee4\uff1ayum search<\/p>\n<\/li>\n<li>\n<p>8.\u6e05\u9664\u7f13\u5b58\u547d\u4ee4:<\/p>\n<\/li>\n<ul>\n<li>\n<p>yum clean packages: \u6e05\u9664\u7f13\u5b58\u76ee\u5f55\u4e0b\u7684\u8f6f\u4ef6\u5305<\/p>\n<\/li>\n<li>\n<p>yum clean headers: \u6e05\u9664\u7f13\u5b58\u76ee\u5f55\u4e0b\u7684 headers<\/p>\n<\/li>\n<li>\n<p>yum clean oldheaders: \u6e05\u9664\u7f13\u5b58\u76ee\u5f55\u4e0b\u65e7\u7684 headers<\/p>\n<\/li>\n<li>\n<p>yum clean, yum clean all (= yum clean packages; yum clean oldheaders) :\u6e05\u9664\u7f13\u5b58\u76ee\u5f55\u4e0b\u7684\u8f6f\u4ef6\u5305\u53ca\u65e7\u7684headers<\/p>\n<\/li>\n<\/ul>\n<\/ul>\n<h3>\u5b9e\u4f8b 1<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b89\u88c5 pam-devel<\/p>\n<pre>[root@www&nbsp;~]&nbsp;yum&nbsp;install&nbsp;pam-develSetting&nbsp;up&nbsp;Install&nbsp;ProcessParsing&nbsp;package&nbsp;install&nbsp;argumentsResolving&nbsp;Dependencies&nbsp;&nbsp;&nbsp;Running&nbsp;transaction&nbsp;check---&amp;gt;&nbsp;Package&nbsp;pam-devel.i386&nbsp;0:0.99.6.2-4.el5&nbsp;set&nbsp;to&nbsp;be&nbsp;updated--&amp;gt;&nbsp;Processing&nbsp;Dependency:&nbsp;pam&nbsp;=&nbsp;0.99.6.2-4.el5&nbsp;for&nbsp;package:&nbsp;pam-devel--&amp;gt;&nbsp;Running&nbsp;transaction&nbsp;check---&amp;gt;&nbsp;Package&nbsp;pam.i386&nbsp;0:0.99.6.2-4.el5&nbsp;set&nbsp;to&nbsp;be&nbsp;updatedfilelists.xml.gz&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;100%&nbsp;|=========================|&nbsp;1.6&nbsp;MB&nbsp;&nbsp;&nbsp;&nbsp;00:05filelists.xml.gz&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;100%&nbsp;|=========================|&nbsp;138&nbsp;kB&nbsp;&nbsp;&nbsp;&nbsp;00:00-&amp;gt;&nbsp;Finished&nbsp;Dependency&nbsp;Resolution\u2026\u2026(\u7701\u7565)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u5b9e\u4f8b 2<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u79fb\u9664 pam-devel<\/p>\n<pre>[root@www&nbsp;~]&nbsp;yum&nbsp;remove&nbsp;pam-develSetting&nbsp;up&nbsp;Remove&nbsp;ProcessResolving&nbsp;Dependencies&nbsp;&nbsp;&nbsp;Running&nbsp;transaction&nbsp;check---&amp;gt;&nbsp;Package&nbsp;pam-devel.i386&nbsp;0:0.99.6.2-4.el5&nbsp;set&nbsp;to&nbsp;be&nbsp;erased--&amp;gt;&nbsp;Finished&nbsp;Dependency&nbsp;ResolutionDependencies&nbsp;Resolved=============================================================================&nbsp;Package&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Arch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Repository&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Size=============================================================================Removing:&nbsp;pam-devel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i386&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.99.6.2-4.el5&nbsp;&nbsp;&nbsp;installed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;495&nbsp;kTransaction&nbsp;Summary=============================================================================Install&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;Package(s)Update&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;Package(s)Remove&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;Package(s)&nbsp;&nbsp;&lt;h3 style=\"outline: 0px;font-size: 18px;font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto rgb center&gt;\u5b9e\u4f8b 3&lt;\/h3&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u5229\u7528 yum \u7684\u529f\u80fd\uff0c\u627e\u51fa\u4ee5 pam \u4e3a\u5f00\u5934\u7684\u8f6f\u4ef6\u540d\u79f0\u6709\u54ea\u4e9b\uff1f&lt;\/p&gt;&lt;pre class=\"brush:php;toolbar:false;\"&gt;[root@www&nbsp;~]&nbsp;yum&nbsp;list&nbsp;pam*Installed&nbsp;Packagespam.i386&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.99.6.2-3.27.el5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;installedpam_ccreds.i386&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3-5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;installedpam_krb5.i386&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.2.14-1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;installedpam_passwdqc.i386&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.0.2-1.2.2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;installedpam_pkcs11.i386&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.5.3-23&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;installedpam_smb.i386&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.1.7-7.2.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;installedAvailable&nbsp;Packages&nbsp;&lt;hr style=\"margin: 1.5em auto;outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto solid rgb&gt;&lt;h2 style=\"outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto rgb center solid&gt;7.3 \u56fd\u5185 yum \u6e90&lt;\/h2&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u7f51\u6613\uff08163\uff09yum\u6e90\u662f\u56fd\u5185\u6700\u597d\u7684yum\u6e90\u4e4b\u4e00 \uff0c\u65e0\u8bba\u662f\u901f\u5ea6\u8fd8\u662f\u8f6f\u4ef6\u7248\u672c\uff0c\u90fd\u975e\u5e38\u7684\u4e0d\u9519\u3002&lt;\/p&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u5c06yum\u6e90\u8bbe\u7f6e\u4e3a163 yum\uff0c\u53ef\u4ee5\u63d0\u5347\u8f6f\u4ef6\u5305\u5b89\u88c5\u548c\u66f4\u65b0\u7684\u901f\u5ea6\uff0c\u540c\u65f6\u907f\u514d\u4e00\u4e9b\u5e38\u89c1\u8f6f\u4ef6\u7248\u672c\u65e0\u6cd5\u627e\u5230\u3002&lt;\/p&gt;&lt;h3 style=\"outline: 0px;font-size: 18px;font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto rgb center&gt;\u5b89\u88c5\u6b65\u9aa4&lt;\/h3&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;\u9996\u5148\u5907\u4efd\/etc\/yum.repos.d\/CentOS-Base.repo&lt;\/p&gt;&lt;pre class=\"brush:php;toolbar:false;\"&gt;mv&nbsp;\/etc\/yum.repos.d\/CentOS-Base.repo&nbsp;\/etc\/yum.repos.d\/CentOS-Base.repo.backup1<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c repo \u6587\u4ef6, \u653e\u5165 \/etc\/yum.repos.d\/ (\u64cd\u4f5c\u524d\u8bf7\u505a\u597d\u76f8\u5e94\u5907\u4efd)<\/p>\n<ul>\n<li>\n<p>CentOS5 \uff1ahttp:\/\/mirrors.163.com\/.help\/CentOS5-Base-163.repo<\/p>\n<\/li>\n<li>\n<p>CentOS6 \uff1ahttp:\/\/mirrors.163.com\/.help\/CentOS6-Base-163.repo<\/p>\n<\/li>\n<li>\n<p>CentOS7 \uff1ahttp:\/\/mirrors.163.com\/.help\/CentOS7-Base-163.repo<\/p>\n<\/li>\n<\/ul>\n<pre>wget&nbsp;http:\/\/mirrors.163.com\/.help\/CentOS6-Base-163.repomv&nbsp;CentOS6-Base-163.repo&nbsp;CentOS-Base.repo<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u7f13\u5b58<\/p>\n<pre>yum&nbsp;clean&nbsp;allyum&nbsp;makecache<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9664\u4e86\u7f51\u6613\u4e4b\u5916\uff0c\u56fd\u5185\u8fd8\u6709\u5176\u4ed6\u4e0d\u9519\u7684 yum \u6e90\uff0c\u6bd4\u5982\u4e2d\u79d1\u5927\u548c\u641c\u72d0\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e2d\u79d1\u5927\u7684 yum \u6e90\uff0c\u5b89\u88c5\u65b9\u6cd5\u67e5\u770b\uff1ahttps:\/\/lug.ustc.edu.cn\/wiki\/mirrors\/help\/centos<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">sohu \u7684 yum \u6e90\u5b89\u88c5\u65b9\u6cd5\u67e5\u770b: http:\/\/mirrors.sohu.com\/help\/centos.htm<\/p>\n<h1>\u516b. Linux \u4e09\u5251\u5ba2\uff08awk\uff0csed\uff0cgrep\uff09<\/h1>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>awk\u3001sed\u3001grep\u66f4\u9002\u5408\u7684\u65b9\u5411\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p>grep \u66f4\u9002\u5408\u5355\u7eaf\u7684\u67e5\u627e\u6216\u5339\u914d\u6587\u672c<\/p>\n<\/li>\n<li>\n<p>sed \u66f4\u9002\u5408\u7f16\u8f91\u5339\u914d\u5230\u7684\u6587\u672c<\/p>\n<\/li>\n<li>\n<p>awk \u66f4\u9002\u5408\u683c\u5f0f\u5316\u6587\u672c\uff0c\u5bf9\u6587\u672c\u8fdb\u884c\u8f83\u590d\u6742\u683c\u5f0f\u5904\u7406<\/p>\n<\/li>\n<\/ul>\n<h2>8.1 awk<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">AWK \u662f\u4e00\u79cd\u5904\u7406\u6587\u672c\u6587\u4ef6\u7684\u8bed\u8a00\uff0c\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6587\u672c\u5206\u6790\u5de5\u5177\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e4b\u6240\u4ee5\u53eb AWK \u662f\u56e0\u4e3a\u5176\u53d6\u4e86\u4e09\u4f4d\u521b\u59cb\u4eba Alfred Aho\uff0cPeter Weinberger, \u548c Brian Kernighan \u7684 Family Name \u7684\u9996\u5b57\u7b26\u3002<\/p>\n<h3>\u8bed\u6cd5<\/h3>\n<pre>awk&nbsp;[\u9009\u9879\u53c2\u6570]&nbsp;'script'&nbsp;var=value&nbsp;file(s)\u6216awk&nbsp;[\u9009\u9879\u53c2\u6570]&nbsp;-f&nbsp;scriptfile&nbsp;var=value&nbsp;file(s)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u9009\u9879\u53c2\u6570\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p>-F fs or \u2014field-separator fs\u6307\u5b9a\u8f93\u5165\u6587\u4ef6\u6298\u5206\u9694\u7b26\uff0cfs\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u6216\u8005\u662f\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u5982-F:\u3002<\/p>\n<\/li>\n<li>\n<p>-v var=value or \u2014asign var=value\u8d4b\u503c\u4e00\u4e2a\u7528\u6237\u5b9a\u4e49\u53d8\u91cf\u3002<\/p>\n<\/li>\n<li>\n<p>-f scripfile or \u2014file scriptfile\u4ece\u811a\u672c\u6587\u4ef6\u4e2d\u8bfb\u53d6awk\u547d\u4ee4\u3002<\/p>\n<\/li>\n<li>\n<p>-mf nnn and -mr nnn\u5bf9nnn\u503c\u8bbe\u7f6e\u5185\u5728\u9650\u5236\uff0c-mf\u9009\u9879\u9650\u5236\u5206\u914d\u7ed9nnn\u7684\u6700\u5927\u5757\u6570\u76ee\uff1b-mr\u9009\u9879\u9650\u5236\u8bb0\u5f55\u7684\u6700\u5927\u6570\u76ee\u3002\u8fd9\u4e24\u4e2a\u529f\u80fd\u662fBell\u5b9e\u9a8c\u5ba4\u7248awk\u7684\u6269\u5c55\u529f\u80fd\uff0c\u5728\u6807\u51c6awk\u4e2d\u4e0d\u9002\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>-W compact or \u2014compat, -W traditional or \u2014traditional\u5728\u517c\u5bb9\u6a21\u5f0f\u4e0b\u8fd0\u884cawk\u3002\u6240\u4ee5gawk\u7684\u884c\u4e3a\u548c\u6807\u51c6\u7684awk\u5b8c\u5168\u4e00\u6837\uff0c\u6240\u6709\u7684awk\u6269\u5c55\u90fd\u88ab\u5ffd\u7565\u3002<\/p>\n<\/li>\n<li>\n<p>-W copyleft or \u2014copyleft, -W copyright or \u2014copyright\u6253\u5370\u7b80\u77ed\u7684\u7248\u6743\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p>-W help or \u2014help, -W usage or \u2014usage\u6253\u5370\u5168\u90e8awk\u9009\u9879\u548c\u6bcf\u4e2a\u9009\u9879\u7684\u7b80\u77ed\u8bf4\u660e\u3002<\/p>\n<\/li>\n<li>\n<p>-W lint or \u2014lint\u6253\u5370\u4e0d\u80fd\u5411\u4f20\u7edfunix\u5e73\u53f0\u79fb\u690d\u7684\u7ed3\u6784\u7684\u8b66\u544a\u3002<\/p>\n<\/li>\n<li>\n<p>-W lint-old or \u2014lint-old\u6253\u5370\u5173\u4e8e\u4e0d\u80fd\u5411\u4f20\u7edfunix\u5e73\u53f0\u79fb\u690d\u7684\u7ed3\u6784\u7684\u8b66\u544a\u3002<\/p>\n<\/li>\n<li>\n<p>-W posix\u6253\u5f00\u517c\u5bb9\u6a21\u5f0f\u3002\u4f46\u6709\u4ee5\u4e0b\u9650\u5236\uff0c\u4e0d\u8bc6\u522b\uff1a\/x\u3001\u51fd\u6570\u5173\u952e\u5b57\u3001func\u3001\u6362\u7801\u5e8f\u5217\u4ee5\u53ca\u5f53fs\u662f\u4e00\u4e2a\u7a7a\u683c\u65f6\uff0c\u5c06\u65b0\u884c\u4f5c\u4e3a\u4e00\u4e2a\u57df\u5206\u9694\u7b26\uff1b\u64cd\u4f5c\u7b26<strong><span>&nbsp;<\/span>\u548c<span>&nbsp;<\/span><\/strong>=\u4e0d\u80fd\u4ee3\u66ff^ \u548c ^=\uff1bfflush\u65e0\u6548\u3002<\/p>\n<\/li>\n<li>\n<p>-W re-interval or \u2014re-inerval\u5141\u8bb8\u95f4\u9694\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u4f7f\u7528\uff0c\u53c2\u8003(grep\u4e2d\u7684Posix\u5b57\u7b26\u7c7b)\uff0c\u5982\u62ec\u53f7\u8868\u8fbe\u5f0f[[:alpha:]]\u3002<\/p>\n<\/li>\n<li>\n<p>-W source program-text or \u2014source program-text\u4f7f\u7528program-text\u4f5c\u4e3a\u6e90\u4ee3\u7801\uff0c\u53ef\u4e0e-f\u547d\u4ee4\u6df7\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>-W version or \u2014version\u6253\u5370bug\u62a5\u544a\u4fe1\u606f\u7684\u7248\u672c\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u57fa\u672c\u7528\u6cd5<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">log.txt\u6587\u672c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre>2&nbsp;this&nbsp;is&nbsp;a&nbsp;test3&nbsp;Are&nbsp;you&nbsp;like&nbsp;awkThis's&nbsp;a&nbsp;test10&nbsp;There&nbsp;are&nbsp;orange,apple,mongo<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7528\u6cd5\u4e00\uff1a<\/p>\n<pre>awk&nbsp;'{[pattern]&nbsp;action}'&nbsp;{filenames}&nbsp;&nbsp;&nbsp;#&nbsp;\u884c\u5339\u914d\u8bed\u53e5&nbsp;awk&nbsp;''&nbsp;\u53ea\u80fd\u7528\u5355\u5f15\u53f7<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b9e\u4f8b\uff1a<\/p>\n<pre>#&nbsp;\u6bcf\u884c\u6309\u7a7a\u683c\u6216TAB\u5206\u5272\uff0c\u8f93\u51fa\u6587\u672c\u4e2d\u76841\u30014\u9879&nbsp;$&nbsp;awk&nbsp;'{print&nbsp;$1,$4}'&nbsp;log.txt&nbsp;---------------------------------------------&nbsp;2&nbsp;a&nbsp;3&nbsp;like&nbsp;This's&nbsp;10&nbsp;orange,apple,mongo&nbsp;#&nbsp;\u683c\u5f0f\u5316\u8f93\u51fa&nbsp;$&nbsp;awk&nbsp;'{printf&nbsp;\"%-8s&nbsp;%-10s\n\",$1,$4}'&nbsp;log.txt&nbsp;---------------------------------------------&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;like&nbsp;This's&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;orange,apple,mongo<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7528\u6cd5\u4e8c\uff1a<\/p>\n<pre>awk&nbsp;-F&nbsp;&nbsp;#-F\u76f8\u5f53\u4e8e\u5185\u7f6e\u53d8\u91cfFS,&nbsp;\u6307\u5b9a\u5206\u5272\u5b57\u7b26<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b9e\u4f8b\uff1a<\/p>\n<pre>#&nbsp;\u4f7f\u7528\",\"\u5206\u5272&nbsp;$&nbsp;&nbsp;awk&nbsp;-F,&nbsp;'{print&nbsp;$1,$2}'&nbsp;&nbsp;&nbsp;log.txt&nbsp;---------------------------------------------&nbsp;2&nbsp;this&nbsp;is&nbsp;a&nbsp;test&nbsp;3&nbsp;Are&nbsp;you&nbsp;like&nbsp;awk&nbsp;This's&nbsp;a&nbsp;test&nbsp;10&nbsp;There&nbsp;are&nbsp;orange&nbsp;apple&nbsp;#&nbsp;\u6216\u8005\u4f7f\u7528\u5185\u5efa\u53d8\u91cf&nbsp;$&nbsp;awk&nbsp;'BEGIN{FS=\",\"}&nbsp;{print&nbsp;$1,$2}'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.txt&nbsp;---------------------------------------------&nbsp;2&nbsp;this&nbsp;is&nbsp;a&nbsp;test&nbsp;3&nbsp;Are&nbsp;you&nbsp;like&nbsp;awk&nbsp;This's&nbsp;a&nbsp;test&nbsp;10&nbsp;There&nbsp;are&nbsp;orange&nbsp;apple&nbsp;#&nbsp;\u4f7f\u7528\u591a\u4e2a\u5206\u9694\u7b26.\u5148\u4f7f\u7528\u7a7a\u683c\u5206\u5272\uff0c\u7136\u540e\u5bf9\u5206\u5272\u7ed3\u679c\u518d\u4f7f\u7528\",\"\u5206\u5272&nbsp;$&nbsp;awk&nbsp;-F&nbsp;'[&nbsp;,]'&nbsp;&nbsp;'{print&nbsp;$1,$2,$5}'&nbsp;&nbsp;&nbsp;log.txt&nbsp;---------------------------------------------&nbsp;2&nbsp;this&nbsp;test&nbsp;3&nbsp;Are&nbsp;awk&nbsp;This's&nbsp;a&nbsp;10&nbsp;There&nbsp;apple<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7528\u6cd5\u4e09\uff1a<\/p>\n<pre>awk&nbsp;-v&nbsp;&nbsp;#&nbsp;\u8bbe\u7f6e\u53d8\u91cf<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b9e\u4f8b\uff1a<\/p>\n<pre>&nbsp;$&nbsp;awk&nbsp;-va=1&nbsp;'{print&nbsp;$1,$1+a}'&nbsp;log.txt&nbsp;---------------------------------------------&nbsp;2&nbsp;3&nbsp;3&nbsp;4&nbsp;This's&nbsp;1&nbsp;10&nbsp;11&nbsp;$&nbsp;awk&nbsp;-va=1&nbsp;-vb=s&nbsp;'{print&nbsp;$1,$1+a,$1b}'&nbsp;log.txt&nbsp;---------------------------------------------&nbsp;2&nbsp;3&nbsp;2s&nbsp;3&nbsp;4&nbsp;3s&nbsp;This's&nbsp;1&nbsp;This'ss&nbsp;10&nbsp;11&nbsp;10s<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7528\u6cd5\u56db\uff1a<\/p>\n<pre>awk&nbsp;-f&nbsp;{awk\u811a\u672c}&nbsp;{\u6587\u4ef6\u540d}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b9e\u4f8b\uff1a<\/p>\n<pre>&nbsp;$&nbsp;awk&nbsp;-f&nbsp;cal.awk&nbsp;log.txt<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u8fd0\u7b97\u7b26<\/h3>\n<table width=\"677\">\n<thead>\n<tr>\n<th style=\"border-top-width: 1px;font-size: 16px\">\u8fd0\u7b97\u7b26<\/th>\n<th style=\"border-top-width: 1px;font-size: 16px\">\u63cf\u8ff0<\/th>\n<th style=\"border-top-width: 1px;font-size: 16px\"><\/th>\n<th style=\"border-top-width: 1px;font-size: 16px\"><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 16px\">= += -=<span>&nbsp;<\/span><em>= \/= %= ^= *<\/em>=<\/td>\n<td style=\"font-size: 16px\">\u8d4b\u503c<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">?:<\/td>\n<td style=\"font-size: 16px\">C\u6761\u4ef6\u8868\u8fbe\u5f0f<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\">\u903b\u8f91\u6216<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">&amp;&amp;<\/td>\n<td style=\"font-size: 16px\">\u903b\u8f91\u4e0e<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">~ \u548c !~<\/td>\n<td style=\"font-size: 16px\">\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u548c\u4e0d\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\"> &gt;= != ==<\/td>\n<td style=\"font-size: 16px\">\u5173\u7cfb\u8fd0\u7b97\u7b26<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">\u7a7a\u683c<\/td>\n<td style=\"font-size: 16px\">\u8fde\u63a5<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">+ &#8211;<\/td>\n<td style=\"font-size: 16px\">\u52a0\uff0c\u51cf<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">* \/ %<\/td>\n<td style=\"font-size: 16px\">\u4e58\uff0c\u9664\u4e0e\u6c42\u4f59<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">+ &#8211; !<\/td>\n<td style=\"font-size: 16px\">\u4e00\u5143\u52a0\uff0c\u51cf\u548c\u903b\u8f91\u975e<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">^<span>&nbsp;<\/span><em>*<\/em> <\/td>\n<td style=\"font-size: 16px\">\u6c42\u5e42<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">++ \u2013<\/td>\n<td style=\"font-size: 16px\">\u589e\u52a0\u6216\u51cf\u5c11\uff0c\u4f5c\u4e3a\u524d\u7f00\u6216\u540e\u7f00<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">$<\/td>\n<td style=\"font-size: 16px\">\u5b57\u6bb5\u5f15\u7528<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">in<\/td>\n<td style=\"font-size: 16px\">\u6570\u7ec4\u6210\u5458<\/td>\n<td style=\"font-size: 16px\"><\/td>\n<td style=\"font-size: 16px\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fc7\u6ee4\u7b2c\u4e00\u5217\u5927\u4e8e2\u7684\u884c<\/p>\n<pre>$&nbsp;awk&nbsp;'$1&amp;gt;2'&nbsp;log.txt&nbsp;&nbsp;&nbsp;&nbsp;#\u547d\u4ee4#\u8f93\u51fa3&nbsp;Are&nbsp;you&nbsp;like&nbsp;awkThis's&nbsp;a&nbsp;test10&nbsp;There&nbsp;are&nbsp;orange,apple,mongo12345<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fc7\u6ee4\u7b2c\u4e00\u5217\u7b49\u4e8e2\u7684\u884c<\/p>\n<pre>$&nbsp;awk&nbsp;'$1==2&nbsp;{print&nbsp;$1,$3}'&nbsp;log.txt&nbsp;&nbsp;&nbsp;&nbsp;#\u547d\u4ee4#\u8f93\u51fa2&nbsp;is123<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8fc7\u6ee4\u7b2c\u4e00\u5217\u5927\u4e8e2\u5e76\u4e14\u7b2c\u4e8c\u5217\u7b49\u4e8e\u2019Are\u2019\u7684\u884c\u3002\u53e6\u5916\uff0c\u641c\u7d22\u516c\u4f17\u53f7Java\u67b6\u6784\u5e08\u6280\u672f\u540e\u53f0\u56de\u590d\u201c\u9762\u8bd5\u9898\u201d\uff0c\u83b7\u53d6\u4e00\u4efd\u60ca\u559c\u793c\u5305\u3002<\/p>\n<pre>$&nbsp;awk&nbsp;'$1&amp;gt;2&nbsp;&amp;amp;&amp;amp;&nbsp;$2==\"Are\"&nbsp;{print&nbsp;$1,$2,$3}'&nbsp;log.txt&nbsp;&nbsp;&nbsp;&nbsp;#\u547d\u4ee4#\u8f93\u51fa3&nbsp;Are&nbsp;you123<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u5185\u5efa\u53d8\u91cf<\/h3>\n<table width=\"677\">\n<thead>\n<tr>\n<th style=\"border-top-width: 1px;font-size: 16px\">\u53d8\u91cf<\/th>\n<th style=\"border-top-width: 1px;font-size: 16px\">\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 16px\">$n<\/td>\n<td style=\"font-size: 16px\">\u5f53\u524d\u8bb0\u5f55\u7684\u7b2cn\u4e2a\u5b57\u6bb5\uff0c\u5b57\u6bb5\u95f4\u7531FS\u5206\u9694<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">$0<\/td>\n<td style=\"font-size: 16px\">\u5b8c\u6574\u7684\u8f93\u5165\u8bb0\u5f55<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">ARGC<\/td>\n<td style=\"font-size: 16px\">\u547d\u4ee4\u884c\u53c2\u6570\u7684\u6570\u76ee<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">ARGIND<\/td>\n<td style=\"font-size: 16px\">\u547d\u4ee4\u884c\u4e2d\u5f53\u524d\u6587\u4ef6\u7684\u4f4d\u7f6e(\u4ece0\u5f00\u59cb\u7b97)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">ARGV<\/td>\n<td style=\"font-size: 16px\">\u5305\u542b\u547d\u4ee4\u884c\u53c2\u6570\u7684\u6570\u7ec4<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">CONVFMT<\/td>\n<td style=\"font-size: 16px\">\u6570\u5b57\u8f6c\u6362\u683c\u5f0f(\u9ed8\u8ba4\u503c\u4e3a%.6g)ENVIRON\u73af\u5883\u53d8\u91cf\u5173\u8054\u6570\u7ec4<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">ERRNO<\/td>\n<td style=\"font-size: 16px\">\u6700\u540e\u4e00\u4e2a\u7cfb\u7edf\u9519\u8bef\u7684\u63cf\u8ff0<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">FIELDWIDTHS<\/td>\n<td style=\"font-size: 16px\">\u5b57\u6bb5\u5bbd\u5ea6\u5217\u8868(\u7528\u7a7a\u683c\u952e\u5206\u9694)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">FILENAME<\/td>\n<td style=\"font-size: 16px\">\u5f53\u524d\u6587\u4ef6\u540d<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">FNR<\/td>\n<td style=\"font-size: 16px\">\u5404\u6587\u4ef6\u5206\u522b\u8ba1\u6570\u7684\u884c\u53f7<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">FS<\/td>\n<td style=\"font-size: 16px\">\u5b57\u6bb5\u5206\u9694\u7b26(\u9ed8\u8ba4\u662f\u4efb\u4f55\u7a7a\u683c)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">IGNORECASE<\/td>\n<td style=\"font-size: 16px\">\u5982\u679c\u4e3a\u771f\uff0c\u5219\u8fdb\u884c\u5ffd\u7565\u5927\u5c0f\u5199\u7684\u5339\u914d<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">NF<\/td>\n<td style=\"font-size: 16px\">\u4e00\u6761\u8bb0\u5f55\u7684\u5b57\u6bb5\u7684\u6570\u76ee<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">NR<\/td>\n<td style=\"font-size: 16px\">\u5df2\u7ecf\u8bfb\u51fa\u7684\u8bb0\u5f55\u6570\uff0c\u5c31\u662f\u884c\u53f7\uff0c\u4ece1\u5f00\u59cb<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">OFMT<\/td>\n<td style=\"font-size: 16px\">\u6570\u5b57\u7684\u8f93\u51fa\u683c\u5f0f(\u9ed8\u8ba4\u503c\u662f%.6g)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">OFS<\/td>\n<td style=\"font-size: 16px\">\u8f93\u51fa\u8bb0\u5f55\u5206\u9694\u7b26\uff08\u8f93\u51fa\u6362\u884c\u7b26\uff09\uff0c\u8f93\u51fa\u65f6\u7528\u6307\u5b9a\u7684\u7b26\u53f7\u4ee3\u66ff\u6362\u884c\u7b26<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">ORS<\/td>\n<td style=\"font-size: 16px\">\u8f93\u51fa\u8bb0\u5f55\u5206\u9694\u7b26(\u9ed8\u8ba4\u503c\u662f\u4e00\u4e2a\u6362\u884c\u7b26)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">RLENGTH<\/td>\n<td style=\"font-size: 16px\">\u7531match\u51fd\u6570\u6240\u5339\u914d\u7684\u5b57\u7b26\u4e32\u7684\u957f\u5ea6<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">RS<\/td>\n<td style=\"font-size: 16px\">\u8bb0\u5f55\u5206\u9694\u7b26(\u9ed8\u8ba4\u662f\u4e00\u4e2a\u6362\u884c\u7b26)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">RSTART<\/td>\n<td style=\"font-size: 16px\">\u7531match\u51fd\u6570\u6240\u5339\u914d\u7684\u5b57\u7b26\u4e32\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 16px\">SUBSEP<\/td>\n<td style=\"font-size: 16px\">\u6570\u7ec4\u4e0b\u6807\u5206\u9694\u7b26(\u9ed8\u8ba4\u503c\u662f\/034)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre>$&nbsp;awk&nbsp;'BEGIN{printf&nbsp;\"%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s\n\",\"FILENAME\",\"ARGC\",\"FNR\",\"FS\",\"NF\",\"NR\",\"OFS\",\"ORS\",\"RS\";printf&nbsp;\"---------------------------------------------\n\"}&nbsp;{printf&nbsp;\"%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s\n\",FILENAME,ARGC,FNR,FS,NF,NR,OFS,ORS,RS}'&nbsp;&nbsp;log.txtFILENAME&nbsp;ARGC&nbsp;&nbsp;FNR&nbsp;&nbsp;&nbsp;FS&nbsp;&nbsp;&nbsp;NF&nbsp;&nbsp;&nbsp;NR&nbsp;&nbsp;OFS&nbsp;&nbsp;ORS&nbsp;&nbsp;&nbsp;RS---------------------------------------------log.txt&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;1log.txt&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;2log.txt&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;3log.txt&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;4$&nbsp;awk&nbsp;-F'&nbsp;'BEGIN{printf&nbsp;\"%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s\n\",\"FILENAME\",\"ARGC\",\"FNR\",\"FS\",\"NF\",\"NR\",\"OFS\",\"ORS\",\"RS\";printf&nbsp;\"---------------------------------------------\n\"}&nbsp;{printf&nbsp;\"%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s&nbsp;%4s\n\",FILENAME,ARGC,FNR,FS,NF,NR,OFS,ORS,RS}'&nbsp;&nbsp;log.txtFILENAME&nbsp;ARGC&nbsp;&nbsp;FNR&nbsp;&nbsp;&nbsp;FS&nbsp;&nbsp;&nbsp;NF&nbsp;&nbsp;&nbsp;NR&nbsp;&nbsp;OFS&nbsp;&nbsp;ORS&nbsp;&nbsp;&nbsp;RS---------------------------------------------log.txt&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;1log.txt&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;2log.txt&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;3log.txt&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;4#&nbsp;\u8f93\u51fa\u987a\u5e8f\u53f7&nbsp;NR,&nbsp;\u5339\u914d\u6587\u672c\u884c\u53f7$&nbsp;awk&nbsp;'{print&nbsp;NR,FNR,$1,$2,$3}'&nbsp;log.txt---------------------------------------------1&nbsp;1&nbsp;2&nbsp;this&nbsp;is2&nbsp;2&nbsp;3&nbsp;Are&nbsp;you3&nbsp;3&nbsp;This's&nbsp;a&nbsp;test4&nbsp;4&nbsp;10&nbsp;There&nbsp;are#&nbsp;\u6307\u5b9a\u8f93\u51fa\u5206\u5272\u7b26$&nbsp;&nbsp;awk&nbsp;'{print&nbsp;$1,$2,$5}'&nbsp;OFS=\"&nbsp;$&nbsp;\"&nbsp;&nbsp;log.txt---------------------------------------------2&nbsp;$&nbsp;this&nbsp;$&nbsp;test3&nbsp;$&nbsp;Are&nbsp;$&nbsp;awkThis's&nbsp;$&nbsp;a&nbsp;$10&nbsp;$&nbsp;There&nbsp;$<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u4f7f\u7528\u6b63\u5219\uff0c\u5b57\u7b26\u4e32\u5339\u914d<\/h3>\n<pre>#&nbsp;\u8f93\u51fa\u7b2c\u4e8c\u5217\u5305\u542b&nbsp;\"th\"\uff0c\u5e76\u6253\u5370\u7b2c\u4e8c\u5217\u4e0e\u7b2c\u56db\u5217$&nbsp;awk&nbsp;'$2&nbsp;~&nbsp;\/th\/&nbsp;{print&nbsp;$2,$4}'&nbsp;log.txt---------------------------------------------this&nbsp;a<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>~ \u8868\u793a\u6a21\u5f0f\u5f00\u59cb\u3002\/\/ \u4e2d\u662f\u6a21\u5f0f\u3002<\/strong><\/p>\n<pre>#&nbsp;\u8f93\u51fa\u5305\u542b&nbsp;\"re\"&nbsp;\u7684\u884c$&nbsp;awk&nbsp;'\/re\/&nbsp;'&nbsp;log.txt---------------------------------------------3&nbsp;Are&nbsp;you&nbsp;like&nbsp;awk10&nbsp;There&nbsp;are&nbsp;orange,apple,mongo<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<hr>\n<h3>\u5ffd\u7565\u5927\u5c0f\u5199<\/h3>\n<pre>$&nbsp;awk&nbsp;'BEGIN{IGNORECASE=1}&nbsp;\/this\/'&nbsp;log.txt---------------------------------------------2&nbsp;this&nbsp;is&nbsp;a&nbsp;testThis's&nbsp;a&nbsp;test<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<hr>\n<h3>\u6a21\u5f0f\u53d6\u53cd<\/h3>\n<pre>$&nbsp;awk&nbsp;'$2&nbsp;!~&nbsp;\/th\/&nbsp;{print&nbsp;$2,$4}'&nbsp;log.txt---------------------------------------------Are&nbsp;likeaThere&nbsp;orange,apple,mongo$&nbsp;awk&nbsp;'!\/th\/&nbsp;{print&nbsp;$2,$4}'&nbsp;log.txt---------------------------------------------Are&nbsp;likeaThere&nbsp;orange,apple,mongo<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<hr>\n<h3>awk\u811a\u672c<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5173\u4e8e awk \u811a\u672c\uff0c\u6211\u4eec\u9700\u8981\u6ce8\u610f\u4e24\u4e2a\u5173\u952e\u8bcd BEGIN \u548c END\u3002<\/p>\n<ul>\n<li>\n<p>BEGIN{ \u8fd9\u91cc\u9762\u653e\u7684\u662f\u6267\u884c\u524d\u7684\u8bed\u53e5 }<\/p>\n<\/li>\n<li>\n<p>END {\u8fd9\u91cc\u9762\u653e\u7684\u662f\u5904\u7406\u5b8c\u6240\u6709\u7684\u884c\u540e\u8981\u6267\u884c\u7684\u8bed\u53e5 }<\/p>\n<\/li>\n<li>\n<p>{\u8fd9\u91cc\u9762\u653e\u7684\u662f\u5904\u7406\u6bcf\u4e00\u884c\u65f6\u8981\u6267\u884c\u7684\u8bed\u53e5}<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5047\u8bbe\u6709\u8fd9\u4e48\u4e00\u4e2a\u6587\u4ef6\uff08\u5b66\u751f\u6210\u7ee9\u8868\uff09\uff1a<\/p>\n<pre>$&nbsp;cat&nbsp;score.txtMarry&nbsp;&nbsp;&nbsp;2143&nbsp;78&nbsp;84&nbsp;77Jack&nbsp;&nbsp;&nbsp;&nbsp;2321&nbsp;66&nbsp;78&nbsp;45Tom&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2122&nbsp;48&nbsp;77&nbsp;71Mike&nbsp;&nbsp;&nbsp;&nbsp;2537&nbsp;87&nbsp;97&nbsp;95Bob&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2415&nbsp;40&nbsp;57&nbsp;62<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6211\u4eec\u7684 awk \u811a\u672c\u5982\u4e0b\uff1a<\/p>\n<pre>$&nbsp;cat&nbsp;cal.awk#!\/bin\/awk&nbsp;-f#\u8fd0\u884c\u524dBEGIN&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;math&nbsp;=&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;english&nbsp;=&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;computer&nbsp;=&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;\"NAME&nbsp;&nbsp;&nbsp;&nbsp;NO.&nbsp;&nbsp;&nbsp;MATH&nbsp;&nbsp;ENGLISH&nbsp;&nbsp;COMPUTER&nbsp;&nbsp;&nbsp;TOTAL\n\"&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;\"---------------------------------------------\n\"}#\u8fd0\u884c\u4e2d{&nbsp;&nbsp;&nbsp;&nbsp;math+=$3&nbsp;&nbsp;&nbsp;&nbsp;english+=$4&nbsp;&nbsp;&nbsp;&nbsp;computer+=$5&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;\"%-6s&nbsp;%-6s&nbsp;%4d&nbsp;%8d&nbsp;%8d&nbsp;%8d\n\",&nbsp;$1,&nbsp;$2,&nbsp;$3,$4,$5,&nbsp;$3+$4+$5}#\u8fd0\u884c\u540eEND&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;\"---------------------------------------------\n\"&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;\"&nbsp;&nbsp;TOTAL:%10d&nbsp;%8d&nbsp;%8d&nbsp;\n\",&nbsp;math,&nbsp;english,&nbsp;computer&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;\"AVERAGE:%10.2f&nbsp;%8.2f&nbsp;%8.2f\n\",&nbsp;math\/NR,&nbsp;english\/NR,&nbsp;computer\/NR}123456789101112131415161718192021222324<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u6267\u884c\u7ed3\u679c\uff1a<\/p>\n<pre>$&nbsp;awk&nbsp;-f&nbsp;cal.awk&nbsp;score.txtNAME&nbsp;&nbsp;&nbsp;&nbsp;NO.&nbsp;&nbsp;&nbsp;MATH&nbsp;&nbsp;ENGLISH&nbsp;&nbsp;COMPUTER&nbsp;&nbsp;&nbsp;TOTAL---------------------------------------------Marry&nbsp;&nbsp;2143&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;78&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;84&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;77&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;239Jack&nbsp;&nbsp;&nbsp;2321&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;66&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;78&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;45&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;189Tom&nbsp;&nbsp;&nbsp;&nbsp;2122&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;48&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;77&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;71&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;196Mike&nbsp;&nbsp;&nbsp;2537&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;87&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;97&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;95&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;279Bob&nbsp;&nbsp;&nbsp;&nbsp;2415&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;40&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;57&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;62&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;159---------------------------------------------&nbsp;&nbsp;TOTAL:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;319&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;393&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;350AVERAGE:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63.80&nbsp;&nbsp;&nbsp;&nbsp;78.60&nbsp;&nbsp;&nbsp;&nbsp;70.00<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<hr>\n<h3>\u53e6\u5916\u4e00\u4e9b\u5b9e\u4f8b<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">AWK \u7684 hello world \u7a0b\u5e8f\u4e3a\uff1a<\/p>\n<pre>BEGIN&nbsp;{&nbsp;print&nbsp;\"Hello,&nbsp;world!\"&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8ba1\u7b97\u6587\u4ef6\u5927\u5c0f<\/p>\n<pre>$&nbsp;ls&nbsp;-l&nbsp;*.txt&nbsp;|&nbsp;awk&nbsp;'{sum+=$5}&nbsp;END&nbsp;{print&nbsp;sum}'--------------------------------------------------666581<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4ece\u6587\u4ef6\u4e2d\u627e\u51fa\u957f\u5ea6\u5927\u4e8e 80 \u7684\u884c\uff1a<\/p>\n<pre>awk&nbsp;'length&amp;gt;80'&nbsp;log.txt<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6253\u5370\u4e5d\u4e5d\u4e58\u6cd5\u8868<\/p>\n<pre>seq&nbsp;9&nbsp;|&nbsp;sed&nbsp;'H;g'&nbsp;|&nbsp;awk&nbsp;-v&nbsp;RS=''&nbsp;'{for(i=1;i&lt;h2 style=\"outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto rgb center solid&gt;8.2 sed&lt;\/h2&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;Linux sed \u547d\u4ee4\u662f\u5229\u7528\u811a\u672c\u6765\u5904\u7406\u6587\u672c\u6587\u4ef6\u3002&lt;\/p&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;sed \u53ef\u4f9d\u7167\u811a\u672c\u7684\u6307\u4ee4\u6765\u5904\u7406\u3001\u7f16\u8f91\u6587\u672c\u6587\u4ef6\u3002&lt;\/p&gt;&lt;p style=\"outline: 0px;caret-color: rgb(34, 34, 34);color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto&gt;Sed \u4e3b\u8981\u7528\u6765\u81ea\u52a8\u7f16\u8f91\u4e00\u4e2a\u6216\u591a\u4e2a\u6587\u4ef6\u3001\u7b80\u5316\u5bf9\u6587\u4ef6\u7684\u53cd\u590d\u64cd\u4f5c\u3001\u7f16\u5199\u8f6c\u6362\u7a0b\u5e8f\u7b49\u3002&lt;\/p&gt;&lt;h3 style=\"outline: 0px;font-size: 18px;font-family: system-ui, -apple-system, BlinkMacSystemFont, \" helvetica neue sc sans gb yahei ui arial sans-serif normal auto rgb center&gt;\u8bed\u6cd5&lt;\/h3&gt;&lt;pre class=\"brush:php;toolbar:false;\"&gt;sed&nbsp;[-hnV][-e&lt;script&gt;][-f&lt;script\u6587\u4ef6&gt;][\u6587\u672c\u6587\u4ef6]&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u53c2\u6570\u8bf4\u660e<\/strong>\uff1a<\/p>\n<ul>\n<li>\n<p>-e&lt;script&gt;\u6216&#8211;expression=&lt;script&gt;&lt;span style=&#8221;outline: 0px;&#8221;&gt; \u4ee5\u9009\u9879\u4e2d\u6307\u5b9a\u7684script\u6765\u5904\u7406\u8f93\u5165\u7684\u6587\u672c\u6587\u4ef6\u3002&lt;\/script&gt;<\/p>\n<\/li>\n<li>\n<p>-f<\/p>\n<p> \u6587\u4ef6&gt;\u6587\u4ef6&gt;<\/li>\n<li>\n<p>-h\u6216\u2013help \u663e\u793a\u5e2e\u52a9\u3002<\/p>\n<\/li>\n<li>\n<p>-n\u6216\u2013quiet\u6216\u2013silent \u4ec5\u663e\u793ascript\u5904\u7406\u540e\u7684\u7ed3\u679c\u3002<\/p>\n<\/li>\n<li>\n<p>-V\u6216\u2013version \u663e\u793a\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<\/li>\n<\/ul>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u52a8\u4f5c\u8bf4\u660e<\/strong>\uff1a<\/p>\n<ul>\n<li>\n<p>a \uff1a\u65b0\u589e\uff0c a \u7684\u540e\u9762\u53ef\u4ee5\u63a5\u5b57\u4e32\uff0c\u800c\u8fd9\u4e9b\u5b57\u4e32\u4f1a\u5728\u65b0\u7684\u4e00\u884c\u51fa\u73b0(\u76ee\u524d\u7684\u4e0b\u4e00\u884c)\uff5e<\/p>\n<\/li>\n<li>\n<p>c \uff1a\u53d6\u4ee3\uff0c c \u7684\u540e\u9762\u53ef\u4ee5\u63a5\u5b57\u4e32\uff0c\u8fd9\u4e9b\u5b57\u4e32\u53ef\u4ee5\u53d6\u4ee3 n1,n2 \u4e4b\u95f4\u7684\u884c\uff01<\/p>\n<\/li>\n<li>\n<p>d \uff1a\u5220\u9664\uff0c\u56e0\u4e3a\u662f\u5220\u9664\u554a\uff0c\u6240\u4ee5 d \u540e\u9762\u901a\u5e38\u4e0d\u63a5\u4efb\u4f55\u549a\u549a\uff1b<\/p>\n<\/li>\n<li>\n<p>i \uff1a\u63d2\u5165\uff0c i \u7684\u540e\u9762\u53ef\u4ee5\u63a5\u5b57\u4e32\uff0c\u800c\u8fd9\u4e9b\u5b57\u4e32\u4f1a\u5728\u65b0\u7684\u4e00\u884c\u51fa\u73b0(\u76ee\u524d\u7684\u4e0a\u4e00\u884c)\uff1b<\/p>\n<\/li>\n<li>\n<p>p \uff1a\u6253\u5370\uff0c\u4ea6\u5373\u5c06\u67d0\u4e2a\u9009\u62e9\u7684\u6570\u636e\u5370\u51fa\u3002\u901a\u5e38 p \u4f1a\u4e0e\u53c2\u6570 sed -n \u4e00\u8d77\u8fd0\u884c\uff5e<\/p>\n<\/li>\n<li>\n<p>s \uff1a\u53d6\u4ee3\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fdb\u884c\u53d6\u4ee3\u7684\u5de5\u4f5c\u54e9\uff01\u901a\u5e38\u8fd9\u4e2a s \u7684\u52a8\u4f5c\u53ef\u4ee5\u642d\u914d\u6b63\u89c4\u8868\u793a\u6cd5\uff01\u4f8b\u5982 1,20s\/old\/new\/g \u5c31\u662f\u5566\uff01<\/p>\n<\/li>\n<\/ul>\n<h3>\u5b9e\u4f8b<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5728testfile\u6587\u4ef6\u7684\u7b2c\u56db\u884c\u540e\u6dfb\u52a0\u4e00\u884c\uff0c\u5e76\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u6807\u51c6\u8f93\u51fa\uff0c\u5728\u547d\u4ee4\u884c\u63d0\u793a\u7b26\u4e0b\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sed&nbsp;-e&nbsp;4a\newLine&nbsp;testfile<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9996\u5148\u67e5\u770btestfile\u4e2d\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre>$&nbsp;cat&nbsp;testfile&nbsp;#\u67e5\u770btestfile&nbsp;\u4e2d\u7684\u5185\u5bb9&nbsp;&nbsp;HELLO&nbsp;LINUX!&nbsp;&nbsp;Linux&nbsp;is&nbsp;a&nbsp;free&nbsp;unix-type&nbsp;opterating&nbsp;system.&nbsp;&nbsp;This&nbsp;is&nbsp;a&nbsp;linux&nbsp;testfile!&nbsp;&nbsp;Linux&nbsp;test<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528sed\u547d\u4ee4\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre>$&nbsp;sed&nbsp;-e&nbsp;4a\newline&nbsp;testfile&nbsp;#\u4f7f\u7528sed&nbsp;\u5728\u7b2c\u56db\u884c\u540e\u6dfb\u52a0\u65b0\u5b57\u7b26\u4e32&nbsp;&nbsp;HELLO&nbsp;LINUX!&nbsp;#testfile\u6587\u4ef6\u539f\u6709\u7684\u5185\u5bb9&nbsp;&nbsp;Linux&nbsp;is&nbsp;a&nbsp;free&nbsp;unix-type&nbsp;opterating&nbsp;system.&nbsp;&nbsp;This&nbsp;is&nbsp;a&nbsp;linux&nbsp;testfile!&nbsp;&nbsp;Linux&nbsp;test&nbsp;&nbsp;newline<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u4ee5\u884c\u4e3a\u5355\u4f4d\u7684\u65b0\u589e\/\u5220\u9664<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06 \/etc\/passwd \u7684\u5185\u5bb9\u5217\u51fa\u5e76\u4e14\u5217\u5370\u884c\u53f7\uff0c\u540c\u65f6\uff0c\u8bf7\u5c06\u7b2c 2~5 \u884c\u5220\u9664\uff01<\/p>\n<pre>[root@www&nbsp;~]&nbsp;nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;'2,5d'1&nbsp;root:x:0:0:root:\/root:\/bin\/bash6&nbsp;sync:x:5:0:sync:\/sbin:\/bin\/sync7&nbsp;shutdown:x:6:0:shutdown:\/sbin:\/sbin\/shutdown.....(\u540e\u9762\u7701\u7565).....<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">sed \u7684\u52a8\u4f5c\u4e3a \u20182,5d\u2019 \uff0c\u90a3\u4e2a d \u5c31\u662f\u5220\u9664\uff01\u56e0\u4e3a 2-5 \u884c\u7ed9\u4ed6\u5220\u9664\u4e86\uff0c\u6240\u4ee5\u663e\u793a\u7684\u6570\u636e\u5c31\u6ca1\u6709 2-5 \u884c\u7f57\uff5e \u53e6\u5916\uff0c\u6ce8\u610f\u4e00\u4e0b\uff0c\u539f\u672c\u5e94\u8be5\u662f\u8981\u4e0b\u8fbe sed -e \u624d\u5bf9\uff0c\u6ca1\u6709 -e \u4e5f\u884c\u5566\uff01\u540c\u65f6\u4e5f\u8981\u6ce8\u610f\u7684\u662f\uff0c sed \u540e\u9762\u63a5\u7684\u52a8\u4f5c\uff0c\u8bf7\u52a1\u5fc5\u4ee5 \u2018\u2019 \u4e24\u4e2a\u5355\u5f15\u53f7\u62ec\u4f4f\u5594\uff01<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53ea\u8981\u5220\u9664\u7b2c 2 \u884c<\/p>\n<pre>nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;'2d'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8981\u5220\u9664\u7b2c 3 \u5230\u6700\u540e\u4e00\u884c<\/p>\n<pre>nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;'3,$d'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5728\u7b2c\u4e8c\u884c\u540e(\u4ea6\u5373\u662f\u52a0\u5728\u7b2c\u4e09\u884c)\u52a0\u4e0a\u300edrink tea?\u300f\u5b57\u6837\uff01<\/p>\n<pre>[root@www&nbsp;~]&nbsp;nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;'2a&nbsp;drink&nbsp;tea'1&nbsp;root:x:0:0:root:\/root:\/bin\/bash2&nbsp;bin:x:1:1:bin:\/bin:\/sbin\/nologindrink&nbsp;tea3&nbsp;daemon:x:2:2:daemon:\/sbin:\/sbin\/nologin.....(\u540e\u9762\u7701\u7565).....<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u90a3\u5982\u679c\u662f\u8981\u5728\u7b2c\u4e8c\u884c\u524d<\/p>\n<pre>nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;'2i&nbsp;drink&nbsp;tea'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5982\u679c\u662f\u8981\u589e\u52a0\u4e24\u884c\u4ee5\u4e0a\uff0c\u5728\u7b2c\u4e8c\u884c\u540e\u9762\u52a0\u5165\u4e24\u884c\u5b57\uff0c\u4f8b\u5982<span>&nbsp;<\/span><strong>Drink tea or \u2026<\/strong><span>&nbsp;<\/span>\u4e0e<span>&nbsp;<\/span><strong>drink beer?<\/strong><\/p>\n<pre>[root@www&nbsp;~]&nbsp;nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;'2a&nbsp;Drink&nbsp;tea&nbsp;or&nbsp;......&amp;gt;&nbsp;drink&nbsp;beer&nbsp;?'1&nbsp;root:x:0:0:root:\/root:\/bin\/bash2&nbsp;bin:x:1:1:bin:\/bin:\/sbin\/nologinDrink&nbsp;tea&nbsp;or&nbsp;......drink&nbsp;beer&nbsp;?3&nbsp;daemon:x:2:2:daemon:\/sbin:\/sbin\/nologin.....(\u540e\u9762\u7701\u7565).....<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6bcf\u4e00\u884c\u4e4b\u95f4\u90fd\u5fc5\u987b\u8981\u4ee5\u53cd\u659c\u6760\u300e \u300f\u6765\u8fdb\u884c\u65b0\u884c\u7684\u6dfb\u52a0\u5594\uff01\u6240\u4ee5\uff0c\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u5728\u7b2c\u4e00\u884c\u7684\u6700\u540e\u9762\u5c31\u6709 \u5b58\u5728\u3002<\/p>\n<h3>\u4ee5\u884c\u4e3a\u5355\u4f4d\u7684\u66ff\u6362\u4e0e\u663e\u793a<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06\u7b2c2-5\u884c\u7684\u5185\u5bb9\u53d6\u4ee3\u6210\u4e3a\u300eNo 2-5 number\u300f\u5462\uff1f<\/p>\n<pre>[root@www&nbsp;~]&nbsp;nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;'2,5c&nbsp;No&nbsp;2-5&nbsp;number'1&nbsp;root:x:0:0:root:\/root:\/bin\/bashNo&nbsp;2-5&nbsp;number6&nbsp;sync:x:5:0:sync:\/sbin:\/bin\/sync.....(\u540e\u9762\u7701\u7565).....<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u900f\u8fc7\u8fd9\u4e2a\u65b9\u6cd5\u6211\u4eec\u5c31\u80fd\u591f\u5c06\u6570\u636e\u6574\u884c\u53d6\u4ee3\u4e86\uff01<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4ec5\u5217\u51fa \/etc\/passwd \u6587\u4ef6\u5185\u7684\u7b2c 5-7 \u884c<\/p>\n<pre>[root@www&nbsp;~]&nbsp;nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;-n&nbsp;'5,7p'5&nbsp;lp:x:4:7:lp:\/var\/spool\/lpd:\/sbin\/nologin6&nbsp;sync:x:5:0:sync:\/sbin:\/bin\/sync7&nbsp;shutdown:x:6:0:shutdown:\/sbin:\/sbin\/shutdown<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u53ef\u4ee5\u900f\u8fc7\u8fd9\u4e2a sed \u7684\u4ee5\u884c\u4e3a\u5355\u4f4d\u7684\u663e\u793a\u529f\u80fd\uff0c \u5c31\u80fd\u591f\u5c06\u67d0\u4e00\u4e2a\u6587\u4ef6\u5185\u7684\u67d0\u4e9b\u884c\u53f7\u9009\u62e9\u51fa\u6765\u663e\u793a\u3002<\/p>\n<h3>\u6570\u636e\u7684\u641c\u5bfb\u5e76\u663e\u793a<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u641c\u7d22 \/etc\/passwd\u6709root\u5173\u952e\u5b57\u7684\u884c<\/p>\n<pre>nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;'\/root\/p'1&nbsp;&nbsp;root:x:0:0:root:\/root:\/bin\/bash1&nbsp;&nbsp;root:x:0:0:root:\/root:\/bin\/bash2&nbsp;&nbsp;daemon:x:1:1:daemon:\/usr\/sbin:\/bin\/sh3&nbsp;&nbsp;bin:x:2:2:bin:\/bin:\/bin\/sh4&nbsp;&nbsp;sys:x:3:3:sys:\/dev:\/bin\/sh5&nbsp;&nbsp;sync:x:4:65534:sync:\/bin:\/bin\/sync....\u4e0b\u9762\u5ffd\u7565<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5982\u679croot\u627e\u5230\uff0c\u9664\u4e86\u8f93\u51fa\u6240\u6709\u884c\uff0c\u8fd8\u4f1a\u8f93\u51fa\u5339\u914d\u884c\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f7f\u7528-n\u7684\u65f6\u5019\u5c06\u53ea\u6253\u5370\u5305\u542b\u6a21\u677f\u7684\u884c\u3002<\/p>\n<pre>nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;-n&nbsp;'\/root\/p'1&nbsp;&nbsp;root:x:0:0:root:\/root:\/bin\/bash<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u6570\u636e\u7684\u641c\u5bfb\u5e76\u5220\u9664<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5220\u9664\/etc\/passwd\u6240\u6709\u5305\u542broot\u7684\u884c\uff0c\u5176\u4ed6\u884c\u8f93\u51fa<\/p>\n<pre>nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;&nbsp;'\/root\/d'2&nbsp;&nbsp;daemon:x:1:1:daemon:\/usr\/sbin:\/bin\/sh3&nbsp;&nbsp;bin:x:2:2:bin:\/bin:\/bin\/sh....\u4e0b\u9762\u5ffd\u7565#\u7b2c\u4e00\u884c\u7684\u5339\u914droot\u5df2\u7ecf\u5220\u9664\u4e86<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u6570\u636e\u7684\u641c\u5bfb\u5e76\u6267\u884c\u547d\u4ee4<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u641c\u7d22\/etc\/passwd,\u627e\u5230root\u5bf9\u5e94\u7684\u884c\uff0c\u6267\u884c\u540e\u9762\u82b1\u62ec\u53f7\u4e2d\u7684\u4e00\u7ec4\u547d\u4ee4\uff0c\u6bcf\u4e2a\u547d\u4ee4\u4e4b\u95f4\u7528\u5206\u53f7\u5206\u9694\uff0c\u8fd9\u91cc\u628abash\u66ff\u6362\u4e3ablueshell\uff0c\u518d\u8f93\u51fa\u8fd9\u884c\uff1a<\/p>\n<pre>nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;-n&nbsp;'\/root\/{s\/bash\/blueshell\/;p;q}'&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;root:x:0:0:root:\/root:\/bin\/blueshell<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6700\u540e\u7684q\u662f\u9000\u51fa\u3002<\/p>\n<h3>\u6570\u636e\u7684\u641c\u5bfb\u5e76\u66ff\u6362<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u9664\u4e86\u6574\u884c\u7684\u5904\u7406\u6a21\u5f0f\u4e4b\u5916\uff0c sed \u8fd8\u53ef\u4ee5\u7528\u884c\u4e3a\u5355\u4f4d\u8fdb\u884c\u90e8\u5206\u6570\u636e\u7684\u641c\u5bfb\u5e76\u53d6\u4ee3\u3002\u57fa\u672c\u4e0a sed \u7684\u641c\u5bfb\u4e0e\u66ff\u4ee3\u7684\u4e0e vi \u76f8\u5f53\u7684\u7c7b\u4f3c\uff01\u4ed6\u6709\u70b9\u50cf\u8fd9\u6837\uff1a<\/p>\n<pre>sed&nbsp;'s\/\u8981\u88ab\u53d6\u4ee3\u7684\u5b57\u4e32\/\u65b0\u7684\u5b57\u4e32\/g'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5148\u89c2\u5bdf\u539f\u59cb\u4fe1\u606f\uff0c\u5229\u7528 \/sbin\/ifconfig \u67e5\u8be2 IP<\/p>\n<pre>[root@www&nbsp;~]&nbsp;\/sbin\/ifconfig&nbsp;eth0eth0&nbsp;Link&nbsp;encap:Ethernet&nbsp;HWaddr&nbsp;00:90:CC:A6:34:84inet&nbsp;addr:192.168.1.100&nbsp;Bcast:192.168.1.255&nbsp;Mask:255.255.255.0inet6&nbsp;addr:&nbsp;fe80::290:ccff:fea6:3484\/64&nbsp;Scope:LinkUP&nbsp;BROADCAST&nbsp;RUNNING&nbsp;MULTICAST&nbsp;MTU:1500&nbsp;Metric:1.....(\u4ee5\u4e0b\u7701\u7565).....<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u672c\u673a\u7684ip\u662f192.168.1.100\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06 IP \u524d\u9762\u7684\u90e8\u5206\u4e88\u4ee5\u5220\u9664<\/p>\n<pre>[root@www&nbsp;~]&nbsp;\/sbin\/ifconfig&nbsp;eth0&nbsp;|&nbsp;grep&nbsp;'inet&nbsp;addr'&nbsp;|&nbsp;sed&nbsp;'s\/^.*addr:\/\/g'192.168.1.100&nbsp;Bcast:192.168.1.255&nbsp;Mask:255.255.255.0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u63a5\u4e0b\u6765\u5219\u662f\u5220\u9664\u540e\u7eed\u7684\u90e8\u5206\uff0c\u4ea6\u5373\uff1a192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5c06 IP \u540e\u9762\u7684\u90e8\u5206\u4e88\u4ee5\u5220\u9664<\/p>\n<pre>[root@www&nbsp;~]&nbsp;\/sbin\/ifconfig&nbsp;eth0&nbsp;|&nbsp;grep&nbsp;'inet&nbsp;addr'&nbsp;|&nbsp;sed&nbsp;'s\/^.*addr:\/\/g'&nbsp;|&nbsp;sed&nbsp;'s\/Bcast.*$\/\/g'192.168.1.100<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u591a\u70b9\u7f16\u8f91<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4e00\u6761sed\u547d\u4ee4\uff0c\u5220\u9664\/etc\/passwd\u7b2c\u4e09\u884c\u5230\u672b\u5c3e\u7684\u6570\u636e\uff0c\u5e76\u628abash\u66ff\u6362\u4e3ablueshell<\/p>\n<pre>nl&nbsp;\/etc\/passwd&nbsp;|&nbsp;sed&nbsp;-e&nbsp;'3,$d'&nbsp;-e&nbsp;'s\/bash\/blueshell\/'1&nbsp;&nbsp;root:x:0:0:root:\/root:\/bin\/blueshell2&nbsp;&nbsp;daemon:x:1:1:daemon:\/usr\/sbin:\/bin\/sh<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">-e\u8868\u793a\u591a\u70b9\u7f16\u8f91\uff0c\u7b2c\u4e00\u4e2a\u7f16\u8f91\u547d\u4ee4\u5220\u9664\/etc\/passwd\u7b2c\u4e09\u884c\u5230\u672b\u5c3e\u7684\u6570\u636e\uff0c\u7b2c\u4e8c\u6761\u547d\u4ee4\u641c\u7d22bash\u66ff\u6362\u4e3ablueshell\u3002<\/p>\n<h3>\u76f4\u63a5\u4fee\u6539\u6587\u4ef6\u5185\u5bb9(\u5371\u9669\u52a8\u4f5c)<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">sed \u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u4e0d\u5fc5\u4f7f\u7528\u7ba1\u9053\u547d\u4ee4\u6216\u6570\u636e\u6d41\u91cd\u5bfc\u5411\uff01\u4e0d\u8fc7\uff0c\u7531\u65bc\u8fd9\u4e2a\u52a8\u4f5c\u4f1a\u76f4\u63a5\u4fee\u6539\u5230\u539f\u59cb\u7684\u6587\u4ef6\uff0c\u6240\u4ee5\u8bf7\u4f60\u5343\u4e07\u4e0d\u8981\u968f\u4fbf\u62ff\u7cfb\u7edf\u914d\u7f6e\u6765\u6d4b\u8bd5\uff01\u6211\u4eec\u8fd8\u662f\u4f7f\u7528\u6587\u4ef6 regular_express.txt \u6587\u4ef6\u6765\u6d4b\u8bd5\u770b\u770b\u5427\uff01<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">regular_express.txt \u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre>[root@www&nbsp;~]&nbsp;cat&nbsp;regular_express.txt&nbsp;runoob.google.taobao.facebook.zhihu-weibo-<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5229\u7528 sed \u5c06 regular_express.txt \u5185\u6bcf\u4e00\u884c\u7ed3\u5c3e\u82e5\u4e3a . \u5219\u6362\u6210 !<\/p>\n<pre>[root@www&nbsp;~]&nbsp;sed&nbsp;-i&nbsp;'s\/.$\/!\/g'&nbsp;regular_express.txt[root@www&nbsp;~]&nbsp;cat&nbsp;regular_express.txt&nbsp;runoob!google!taobao!facebook!zhihu-weibo-<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">:q:q<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5229\u7528 sed \u76f4\u63a5\u5728 regular_express.txt \u6700\u540e\u4e00\u884c\u52a0\u5165<span>&nbsp;<\/span><strong># This is a test<\/strong>:<\/p>\n<pre>[root@www&nbsp;~]&nbsp;sed&nbsp;-i&nbsp;'$a&nbsp;#&nbsp;This&nbsp;is&nbsp;a&nbsp;test'&nbsp;regular_express.txt[root@www&nbsp;~]&nbsp;cat&nbsp;regular_express.txt&nbsp;runoob!google!taobao!facebook!zhihu-weibo-#&nbsp;This&nbsp;is&nbsp;a&nbsp;test<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7531\u65bc $ \u4ee3\u8868\u7684\u662f\u6700\u540e\u4e00\u884c\uff0c\u800c a \u7684\u52a8\u4f5c\u662f\u65b0\u589e\uff0c\u56e0\u6b64\u8be5\u6587\u4ef6\u6700\u540e\u65b0\u589e<span>&nbsp;<\/span><strong># This is a test<\/strong>\uff01<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">sed \u7684<span>&nbsp;<\/span><strong>-i<\/strong><span>&nbsp;<\/span>\u9009\u9879\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u6587\u4ef6\u5185\u5bb9\uff0c\u8fd9\u529f\u80fd\u975e\u5e38\u6709\u5e2e\u52a9\uff01\u4e3e\u4f8b\u6765\u8bf4\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2a 100 \u4e07\u884c\u7684\u6587\u4ef6\uff0c\u4f60\u8981\u5728\u7b2c 100 \u884c\u52a0\u67d0\u4e9b\u6587\u5b57\uff0c\u6b64\u65f6\u4f7f\u7528 vim \u53ef\u80fd\u4f1a\u75af\u6389\uff01\u56e0\u4e3a\u6587\u4ef6\u592a\u5927\u4e86\uff01\u90a3\u600e\u529e\uff1f\u5c31\u5229\u7528 sed \u554a\uff01\u900f\u8fc7 sed \u76f4\u63a5\u4fee\u6539\/\u53d6\u4ee3\u7684\u529f\u80fd\uff0c\u4f60\u751a\u81f3\u4e0d\u9700\u8981\u4f7f\u7528 vim \u53bb\u4fee\u8ba2\uff01<\/p>\n<h3>\u8ffd\u52a0\u884c\u7684\u8bf4\u660e\uff1a<\/h3>\n<pre>sed&nbsp;-e&nbsp;4a\newLine&nbsp;testfile<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">a \u52a8\u4f5c\u662f\u5728\u5339\u914d\u7684\u884c\u4e4b\u540e\u8ffd\u52a0\u5b57\u7b26\u4e32\uff0c\u8ffd\u52a0\u7684\u5b57\u7b26\u4e32\u4e2d\u53ef\u4ee5\u5305\u542b\u6362\u884c\u7b26\uff08\u5b9e\u73b0\u8ffd\u52a0\u591a\u884c\u7684\u60c5\u51b5\uff09\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8ffd\u52a0\u4e00\u884c\u7684\u8bdd\u524d\u540e\u90fd\u4e0d\u9700\u8981\u6dfb\u52a0\u6362\u884c\u7b26<span>&nbsp;<\/span><strong> <\/strong>\uff0c\u53ea\u6709\u8ffd\u52a0\u591a\u884c\u65f6\u5728\u884c\u4e0e\u884c\u4e4b\u95f4\u624d\u9700\u8981\u6dfb\u52a0\u6362\u884c\u7b26(\u6700\u540e\u4e00\u884c\u6700\u540e\u4e5f\u65e0\u9700\u6dfb\u52a0\uff0c\u6dfb\u52a0\u7684\u8bdd\u4f1a\u591a\u51fa\u4e00\u4e2a\u7a7a\u884c)\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">man sed \u4fe1\u606f\uff1a<\/p>\n<pre>Append&nbsp;text,&nbsp;which&nbsp;has&nbsp;each&nbsp;embedded&nbsp;newline&nbsp;preceded&nbsp;by&nbsp;a&nbsp;backslash.<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u4f8b\u5982\uff1a<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">4 \u884c\u4e4b\u540e\u6dfb\u52a0\u4e00\u884c\uff1a<\/p>\n<pre>sed&nbsp;-e&nbsp;'4&nbsp;a&nbsp;newline'&nbsp;testfile<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">4 \u884c\u4e4b\u540e\u8ffd\u52a0 2 \u884c\uff1a<\/p>\n<pre>sed&nbsp;-e&nbsp;'4&nbsp;a&nbsp;newline\nnewline2'&nbsp;testfile<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">4 \u884c\u4e4b\u540e\u8ffd\u52a0 3 \u884c(2 \u884c\u6587\u5b57\u548c 1 \u884c\u7a7a\u884c)<\/p>\n<pre>sed&nbsp;-e&nbsp;'4&nbsp;a&nbsp;newline\nnewline2\n'&nbsp;testfile<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">4 \u884c\u4e4b\u540e\u8ffd\u52a0 1 \u884c\u7a7a\u884c\uff1a<\/p>\n<pre>#\u9519\u8bef\uff1ased&nbsp;-e&nbsp;'4&nbsp;a&nbsp;\n'&nbsp;testfilesed&nbsp;-e&nbsp;'4&nbsp;a&nbsp;&nbsp;'&nbsp;testfile&nbsp;\u5b9e\u9645\u4e0a<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u5b9e\u9645\u4e0a\u662f\u63d2\u5165\u4e86\u4e00\u4e2a\u542b\u6709\u4e00\u4e2a\u7a7a\u683c\u7684\u884c\uff0c\u63d2\u5165\u4e00\u4e2a\u5b8c\u5168\u4e3a\u7a7a\u7684\u7a7a\u884c\u6ca1\u6709\u627e\u5230\u65b9\u6cd5\uff08\u4e0d\u8fc7\u5e94\u8be5\u6ca1\u6709\u8fd9\u4e2a\u9700\u6c42\u5427\uff0c\u90fd\u8981\u63d2\u5165\u884c\u4e86\u63d2\u5165\u7a7a\u884c\u5e72\u561b\u5462\uff1f\uff09<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u6dfb\u52a0\u7a7a\u884c\uff1a<\/p>\n<pre>#&nbsp;\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u5b8c\u5168\u4e3a\u7a7a\u7684\u7a7a\u884csed&nbsp;'4&nbsp;a&nbsp;\\'#&nbsp;\u53ef\u4ee5\u6dfb\u52a0\u4e24\u4e2a\u5b8c\u5168\u4e3a\u7a7a\u7684\u7a7a\u884csed&nbsp;'4&nbsp;a&nbsp;\\n'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>8.3 grep<\/h2>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">Linux grep \u547d\u4ee4\u7528\u4e8e\u67e5\u627e\u6587\u4ef6\u91cc\u7b26\u5408\u6761\u4ef6\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">grep \u6307\u4ee4\u7528\u4e8e\u67e5\u627e\u5185\u5bb9\u5305\u542b\u6307\u5b9a\u7684\u8303\u672c\u6837\u5f0f\u7684\u6587\u4ef6\uff0c\u5982\u679c\u53d1\u73b0\u67d0\u6587\u4ef6\u7684\u5185\u5bb9\u7b26\u5408\u6240\u6307\u5b9a\u7684\u8303\u672c\u6837\u5f0f\uff0c\u9884\u8bbe grep \u6307\u4ee4\u4f1a\u628a\u542b\u6709\u8303\u672c\u6837\u5f0f\u7684\u90a3\u4e00\u5217\u663e\u793a\u51fa\u6765\u3002\u82e5\u4e0d\u6307\u5b9a\u4efb\u4f55\u6587\u4ef6\u540d\u79f0\uff0c\u6216\u662f\u6240\u7ed9\u4e88\u7684\u6587\u4ef6\u540d\u4e3a<span>&nbsp;<\/span><strong>&#8211;<\/strong>\uff0c\u5219 grep \u6307\u4ee4\u4f1a\u4ece\u6807\u51c6\u8f93\u5165\u8bbe\u5907\u8bfb\u53d6\u6570\u636e\u3002<\/p>\n<h3>\u8bed\u6cd5<\/h3>\n<pre>grep&nbsp;[-abcEFGhHilLnqrsvVwxy][-A][-B][-C][-d][-e][-f][--help][\u8303\u672c\u6837\u5f0f][\u6587\u4ef6\u6216\u76ee\u5f55...]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><strong>\u53c2\u6570<\/strong>\uff1a<\/p>\n<ul>\n<li>\n<p><strong>-a \u6216 \u2014text<\/strong><span>&nbsp;<\/span>: \u4e0d\u8981\u5ffd\u7565\u4e8c\u8fdb\u5236\u7684\u6570\u636e\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-A \u6216 \u2014after-context=<\/strong><span>&nbsp;<\/span>: \u9664\u4e86\u663e\u793a\u7b26\u5408\u8303\u672c\u6837\u5f0f\u7684\u90a3\u4e00\u5217\u4e4b\u5916\uff0c\u5e76\u663e\u793a\u8be5\u884c\u4e4b\u540e\u7684\u5185\u5bb9\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-b \u6216 \u2014byte-offset<\/strong><span>&nbsp;<\/span>: \u5728\u663e\u793a\u7b26\u5408\u6837\u5f0f\u7684\u90a3\u4e00\u884c\u4e4b\u524d\uff0c\u6807\u793a\u51fa\u8be5\u884c\u7b2c\u4e00\u4e2a\u5b57\u7b26\u7684\u7f16\u53f7\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-B \u6216 \u2014before-context=<\/strong><span>&nbsp;<\/span>: \u9664\u4e86\u663e\u793a\u7b26\u5408\u6837\u5f0f\u7684\u90a3\u4e00\u884c\u4e4b\u5916\uff0c\u5e76\u663e\u793a\u8be5\u884c\u4e4b\u524d\u7684\u5185\u5bb9\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-c \u6216 \u2014count<\/strong><span>&nbsp;<\/span>: \u8ba1\u7b97\u7b26\u5408\u6837\u5f0f\u7684\u5217\u6570\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-C \u6216 \u2014context=\u6216-<\/strong><span>&nbsp;<\/span>: \u9664\u4e86\u663e\u793a\u7b26\u5408\u6837\u5f0f\u7684\u90a3\u4e00\u884c\u4e4b\u5916\uff0c\u5e76\u663e\u793a\u8be5\u884c\u4e4b\u524d\u540e\u7684\u5185\u5bb9\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-d \u6216 \u2014directories=<\/strong><span>&nbsp;<\/span>: \u5f53\u6307\u5b9a\u8981\u67e5\u627e\u7684\u662f\u76ee\u5f55\u800c\u975e\u6587\u4ef6\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528\u8fd9\u9879\u53c2\u6570\uff0c\u5426\u5219grep\u6307\u4ee4\u5c06\u56de\u62a5\u4fe1\u606f\u5e76\u505c\u6b62\u52a8\u4f5c\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-e \u6216 \u2014regexp=<\/strong><span>&nbsp;<\/span>: \u6307\u5b9a\u5b57\u7b26\u4e32\u505a\u4e3a\u67e5\u627e\u6587\u4ef6\u5185\u5bb9\u7684\u6837\u5f0f\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-E \u6216 \u2014extended-regexp<\/strong><span>&nbsp;<\/span>: \u5c06\u6837\u5f0f\u4e3a\u5ef6\u4f38\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u4f7f\u7528\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-f \u6216 \u2014file=<\/strong><span>&nbsp;<\/span>: \u6307\u5b9a\u89c4\u5219\u6587\u4ef6\uff0c\u5176\u5185\u5bb9\u542b\u6709\u4e00\u4e2a\u6216\u591a\u4e2a\u89c4\u5219\u6837\u5f0f\uff0c\u8ba9grep\u67e5\u627e\u7b26\u5408\u89c4\u5219\u6761\u4ef6\u7684\u6587\u4ef6\u5185\u5bb9\uff0c\u683c\u5f0f\u4e3a\u6bcf\u884c\u4e00\u4e2a\u89c4\u5219\u6837\u5f0f\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-F \u6216 \u2014fixed-regexp<\/strong><span>&nbsp;<\/span>: \u5c06\u6837\u5f0f\u89c6\u4e3a\u56fa\u5b9a\u5b57\u7b26\u4e32\u7684\u5217\u8868\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-G \u6216 \u2014basic-regexp<\/strong><span>&nbsp;<\/span>: \u5c06\u6837\u5f0f\u89c6\u4e3a\u666e\u901a\u7684\u8868\u793a\u6cd5\u6765\u4f7f\u7528\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-h \u6216 \u2014no-filename<\/strong><span>&nbsp;<\/span>: \u5728\u663e\u793a\u7b26\u5408\u6837\u5f0f\u7684\u90a3\u4e00\u884c\u4e4b\u524d\uff0c\u4e0d\u6807\u793a\u8be5\u884c\u6240\u5c5e\u7684\u6587\u4ef6\u540d\u79f0\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-H \u6216 \u2014with-filename<\/strong><span>&nbsp;<\/span>: \u5728\u663e\u793a\u7b26\u5408\u6837\u5f0f\u7684\u90a3\u4e00\u884c\u4e4b\u524d\uff0c\u8868\u793a\u8be5\u884c\u6240\u5c5e\u7684\u6587\u4ef6\u540d\u79f0\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-i \u6216 \u2014ignore-case<\/strong><span>&nbsp;<\/span>: \u5ffd\u7565\u5b57\u7b26\u5927\u5c0f\u5199\u7684\u5dee\u522b\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-l \u6216 \u2014file-with-matches<\/strong><span>&nbsp;<\/span>: \u5217\u51fa\u6587\u4ef6\u5185\u5bb9\u7b26\u5408\u6307\u5b9a\u7684\u6837\u5f0f\u7684\u6587\u4ef6\u540d\u79f0\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-L \u6216 \u2014files-without-match<\/strong><span>&nbsp;<\/span>: \u5217\u51fa\u6587\u4ef6\u5185\u5bb9\u4e0d\u7b26\u5408\u6307\u5b9a\u7684\u6837\u5f0f\u7684\u6587\u4ef6\u540d\u79f0\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-n \u6216 \u2014line-number<\/strong><span>&nbsp;<\/span>: \u5728\u663e\u793a\u7b26\u5408\u6837\u5f0f\u7684\u90a3\u4e00\u884c\u4e4b\u524d\uff0c\u6807\u793a\u51fa\u8be5\u884c\u7684\u5217\u6570\u7f16\u53f7\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-o \u6216 \u2014only-matching<\/strong><span>&nbsp;<\/span>: \u53ea\u663e\u793a\u5339\u914dPATTERN \u90e8\u5206\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-q \u6216 \u2014quiet\u6216\u2013silent<\/strong><span>&nbsp;<\/span>: \u4e0d\u663e\u793a\u4efb\u4f55\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-r \u6216 \u2014recursive<\/strong><span>&nbsp;<\/span>: \u6b64\u53c2\u6570\u7684\u6548\u679c\u548c\u6307\u5b9a\u201d-d recurse\u201d\u53c2\u6570\u76f8\u540c\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-s \u6216 \u2014no-messages<\/strong><span>&nbsp;<\/span>: \u4e0d\u663e\u793a\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-v \u6216 \u2014revert-match<\/strong><span>&nbsp;<\/span>: \u663e\u793a\u4e0d\u5305\u542b\u5339\u914d\u6587\u672c\u7684\u6240\u6709\u884c\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-V \u6216 \u2014version<\/strong><span>&nbsp;<\/span>: \u663e\u793a\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-w \u6216 \u2014word-regexp<\/strong><span>&nbsp;<\/span>: \u53ea\u663e\u793a\u5168\u5b57\u7b26\u5408\u7684\u5217\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-x \u2014line-regexp<\/strong><span>&nbsp;<\/span>: \u53ea\u663e\u793a\u5168\u5217\u7b26\u5408\u7684\u5217\u3002<\/p>\n<\/li>\n<li>\n<p><strong>-y<\/strong><span>&nbsp;<\/span>: \u6b64\u53c2\u6570\u7684\u6548\u679c\u548c\u6307\u5b9a\u201d-i\u201d\u53c2\u6570\u76f8\u540c\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u5b9e\u4f8b<\/h3>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">1\u3001\u5728\u5f53\u524d\u76ee\u5f55\u4e2d\uff0c\u67e5\u627e\u540e\u7f00\u6709 file \u5b57\u6837\u7684\u6587\u4ef6\u4e2d\u5305\u542b test \u5b57\u7b26\u4e32\u7684\u6587\u4ef6\uff0c\u5e76\u6253\u5370\u51fa\u8be5\u5b57\u7b26\u4e32\u7684\u884c\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>grep&nbsp;test&nbsp;*file<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>$&nbsp;grep&nbsp;test&nbsp;test*&nbsp;#\u67e5\u627e\u524d\u7f00\u6709\u201ctest\u201d\u7684\u6587\u4ef6\u5305\u542b\u201ctest\u201d\u5b57\u7b26\u4e32\u7684\u6587\u4ef6&nbsp;&nbsp;testfile1:This&nbsp;a&nbsp;Linux&nbsp;testfile!&nbsp;#\u5217\u51fatestfile1&nbsp;\u6587\u4ef6\u4e2d\u5305\u542btest\u5b57\u7b26\u7684\u884c&nbsp;&nbsp;testfile_2:This&nbsp;is&nbsp;a&nbsp;linux&nbsp;testfile!&nbsp;#\u5217\u51fatestfile_2&nbsp;\u6587\u4ef6\u4e2d\u5305\u542btest\u5b57\u7b26\u7684\u884c&nbsp;&nbsp;testfile_2:Linux&nbsp;test&nbsp;#\u5217\u51fatestfile_2&nbsp;\u6587\u4ef6\u4e2d\u5305\u542btest\u5b57\u7b26\u7684\u884c<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">2\u3001\u4ee5\u9012\u5f52\u7684\u65b9\u5f0f\u67e5\u627e\u7b26\u5408\u6761\u4ef6\u7684\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u67e5\u627e\u6307\u5b9a\u76ee\u5f55\/etc\/acpi \u53ca\u5176\u5b50\u76ee\u5f55\uff08\u5982\u679c\u5b58\u5728\u5b50\u76ee\u5f55\u7684\u8bdd\uff09\u4e0b\u6240\u6709\u6587\u4ef6\u4e2d\u5305\u542b\u5b57\u7b26\u4e32\u201dupdate\u201d\u7684\u6587\u4ef6\uff0c\u5e76\u6253\u5370\u51fa\u8be5\u5b57\u7b26\u4e32\u6240\u5728\u884c\u7684\u5185\u5bb9\uff0c\u4f7f\u7528\u7684\u547d\u4ee4\u4e3a\uff1a<\/p>\n<pre>grep&nbsp;-r&nbsp;update&nbsp;\/etc\/acpi<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre>$&nbsp;grep&nbsp;-r&nbsp;update&nbsp;\/etc\/acpi&nbsp;#\u4ee5\u9012\u5f52\u7684\u65b9\u5f0f\u67e5\u627e\u201cetc\/acpi\u201d&nbsp;&nbsp;#\u4e0b\u5305\u542b\u201cupdate\u201d\u7684\u6587\u4ef6&nbsp;&nbsp;\/etc\/acpi\/ac.d\/85-anacron.sh:#&nbsp;(Things&nbsp;like&nbsp;the&nbsp;slocate&nbsp;updatedb&nbsp;cause&nbsp;a&nbsp;lot&nbsp;of&nbsp;IO.)&nbsp;&nbsp;Rather&nbsp;than&nbsp;&nbsp;\/etc\/acpi\/resume.d\/85-anacron.sh:#&nbsp;(Things&nbsp;like&nbsp;the&nbsp;slocate&nbsp;updatedb&nbsp;cause&nbsp;a&nbsp;lot&nbsp;of&nbsp;&nbsp;IO.)&nbsp;Rather&nbsp;than&nbsp;&nbsp;\/etc\/acpi\/events\/thinkpad-cmos:action=\/usr\/sbin\/thinkpad-keys--update<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">3\u3001\u53cd\u5411\u67e5\u627e\u3002\u524d\u9762\u5404\u4e2a\u4f8b\u5b50\u662f\u67e5\u627e\u5e76\u6253\u5370\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u884c\uff0c\u901a\u8fc7\u201d-v\u201d\u53c2\u6570\u53ef\u4ee5\u6253\u5370\u51fa\u4e0d\u7b26\u5408\u6761\u4ef6\u884c\u7684\u5185\u5bb9\u3002<\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u67e5\u627e\u6587\u4ef6\u540d\u4e2d\u5305\u542b test \u7684\u6587\u4ef6\u4e2d\u4e0d\u5305\u542btest \u7684\u884c\uff0c\u6b64\u65f6\uff0c\u4f7f\u7528\u7684\u547d\u4ee4\u4e3a\uff1a<\/p>\n<pre>grep&nbsp;-v&nbsp;test&nbsp;*test*<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"font-family: system-ui, -apple-system, BlinkMacSystemFont,\">\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>$&nbsp;grep-v&nbsp;test*&nbsp;#\u67e5\u627e\u6587\u4ef6\u540d\u4e2d\u5305\u542btest&nbsp;\u7684\u6587\u4ef6\u4e2d\u4e0d\u5305\u542btest&nbsp;\u7684\u884c&nbsp;&nbsp;testfile1:helLinux!&nbsp;&nbsp;testfile1:Linis&nbsp;a&nbsp;free&nbsp;Unix-type&nbsp;operating&nbsp;system.&nbsp;&nbsp;testfile1:Lin&nbsp;&nbsp;testfile_1:HELLO&nbsp;LINUX!&nbsp;&nbsp;testfile_1:LINUX&nbsp;IS&nbsp;A&nbsp;FREE&nbsp;UNIX-TYPE&nbsp;OPTERATING&nbsp;SYSTEM.&nbsp;&nbsp;testfile_1:THIS&nbsp;IS&nbsp;A&nbsp;LINUX&nbsp;TESTFILE!&nbsp;&nbsp;testfile_2:HELLO&nbsp;LINUX!&nbsp;&nbsp;testfile_2:Linux&nbsp;is&nbsp;a&nbsp;free&nbsp;unix-type&nbsp;opterating&nbsp;system.<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLinux\u547d\u4ee4\u5927\u5168\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6ce8\u610f\uff1a\u4e3a\u4e86\u65b9\u4fbf\u4ee3\u7801\u9605\u8bfb\uff0c\u6587\u7ae0\u4ee3\u7801\u5757\u91cc\u628a\u8868\u793a\u7ba1\u7406\u5458\u6a21\u5f0f\u7684#\u90fd\u53bb\u6389\u4e86\u3002\u8fd9\u4e0d\u662f\u9519\u8bef\u3002\u4e0d\u8981\u641e\u9519\uff01\uff01 \u4e00\u3001\u57fa\u672c\u64cd\u4f5c\u547d\u4ee4 \u9996\u5148\u5148\u6765\u51e0\u4e2a\u70ed\u952e\uff0c\u975e\u5e38\u65b9\u4fbf\uff0c\u4e00\u5b9a\u8981\u8bb0\u4f4f Tab\u6309\u952e\u2014\u547d\u4ee4\u8865\u9f50\u529f\u80fd Ctrl+c\u6309\u952e\u2014\u505c\u6389\u6b63\u5728\u8fd0\u884c\u7684\u7a0b\u5e8f Ctrl+d\u6309\u952e\u2014\u76f8\u5f53\u4e8eexit\uff0c\u9000\u51fa Ctrl+l\u6309\u952e\u2014\u6e05\u5c4f 1.1 \u5173\u673a\u548c\u91cd\u542f 1.\u5173\u673a\u547d\u4ee4\uff1ashutdown \u5728\u9886\u57df\u5185\u5927\u591a\u7528\u5728\u670d\u52a1\u5668\u4e0a\uff0c\u5f88\u5c11\u9047\u5230\u5173\u673a\u7684\u64cd\u4f5c\u3002\u6bd5\u7adf\u670d\u52a1\u5668\u4e0a\u8dd1\u4e00\u4e2a\u670d\u52a1\u662f\u6c38\u65e0\u6b62\u5883\u7684\uff0c\u9664\u975e\u7279\u6b8a\u60c5\u51b5\u4e0b\uff0c\u4e0d\u5f97\u5df2\u624d\u4f1a\u5173\u673a\u3002 \u6b63\u786e\u7684\u5173\u673a\u6d41\u7a0b\u4e3a\uff1async &gt; shutdown &gt; reboot &gt; halt \u4f8b\u5982\u4f60\u53ef\u4ee5\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5173\u673a\uff1a sync&nbsp;\u5c06\u6570\u636e\u7531\u5185\u5b58\u540c\u6b65\u5230\u786c\u76d8\u4e2d\u3002shutdown&nbsp;\u5173\u673a\u6307\u4ee4\uff0c\u4f60\u53ef\u4ee5man&nbsp;shutdown&nbsp;\u6765\u770b\u4e00\u4e0b\u5e2e\u52a9\u6587\u6863\u3002\u4f8b\u5982\u4f60\u53ef\u4ee5\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5173\u673a\uff1ashutdown&nbsp;\u2013h&nbsp;10&nbsp;\u2018This&nbsp;server&nbsp;will&nbsp;shutdown&nbsp;after&nbsp;10&nbsp;mins\u2019&nbsp;\u8fd9\u4e2a\u547d\u4ee4\u544a\u8bc9\u5927\u5bb6\uff0c\u8ba1\u7b97\u673a\u5c06\u572810\u5206\u949f\u540e\u5173\u673a\uff0c\u5e76\u4e14\u4f1a\u663e\u793a\u5728\u767b\u9646\u7528\u6237\u7684\u5f53\u524d\u5c4f\u5e55\u4e2d\u3002shutdown&nbsp;\u2013h&nbsp;now&nbsp;\u7acb\u9a6c\u5173\u673ashutdown&nbsp;\u2013h&nbsp;20:25&nbsp;\u7cfb\u7edf\u4f1a\u5728\u4eca\u592920:25\u5173\u673ashutdown&nbsp;\u2013h&nbsp;+10&nbsp;\u5341\u5206\u949f\u540e\u5173\u673ashutdown&nbsp;\u2013r&nbsp;now&nbsp;\u7cfb\u7edf\u7acb\u9a6c\u91cd\u542fshutdown&nbsp;\u2013r&nbsp;+10&nbsp;\u7cfb\u7edf\u5341\u5206\u949f\u540e\u91cd\u542freboot&nbsp;\u5c31\u662f\u91cd\u542f\uff0c\u7b49\u540c\u4e8e&nbsp;shutdown&nbsp;\u2013r&nbsp;nowhalt&nbsp;\u5173\u95ed\u7cfb\u7edf\uff0c\u7b49\u540c\u4e8eshutdown&nbsp;\u2013h&nbsp;now&nbsp;\u548c&nbsp;poweroff \u767b\u5f55\u540e\u590d\u5236 \u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6837\u4f8b\u3002 \u53d6\u6d88\u5b9a\u65f6\u5173\u673a\u547d\u4ee4\uff1ashutdown -c \u6700\u540e\u603b\u7ed3\u4e00\u4e0b\uff0c\u4e0d\u7ba1\u662f\u91cd\u542f\u7cfb\u7edf\u8fd8\u662f\u5173\u95ed\u7cfb\u7edf\uff0c\u9996\u5148\u8981\u8fd0\u884c&nbsp;sync&nbsp;\u547d\u4ee4\uff0c\u628a\u5185\u5b58\u4e2d\u7684\u6570\u636e\u5199\u5230\u78c1\u76d8\u4e2d\u3002 \u5173\u673a\u7684\u547d\u4ee4\u6709&nbsp;shutdown \u2013h now halt poweroff&nbsp;\u548c&nbsp;init 0&nbsp;, \u91cd\u542f\u7cfb\u7edf\u7684\u547d\u4ee4\u6709&nbsp;shutdown \u2013r now reboot init 6\u3002 2.\u91cd\u542f\u547d\u4ee4\uff1areboot 1.2 \u5e2e\u52a9\u547d\u4ee4 \u2013-help\u547d\u4ee4 shutdown&nbsp;&#8211;help\uff1aifconfig&nbsp;&#8211;help\uff1a\u67e5\u770b\u7f51\u5361\u4fe1\u606f \u767b\u5f55\u540e\u590d\u5236 man\u547d\u4ee4\uff08\u547d\u4ee4\u8bf4\u660e\u4e66\uff09 man&nbsp;shutdown\u6ce8\u610f\uff1aman&nbsp;shutdown&nbsp;\u6253\u5f00\u547d\u4ee4\u8bf4\u660e\u4e66\u4e4b\u540e\uff0c\u4f7f\u7528\u6309\u952eq\u9000\u51fa \u767b\u5f55\u540e\u590d\u5236 \u4e8c\u3001\u76ee\u5f55\u64cd\u4f5c\u547d\u4ee4 \u6211\u4eec\u77e5\u9053Linux\u7684\u76ee\u5f55\u7ed3\u6784\u4e3a\u6811\u72b6\u7ed3\u6784\uff0c\u6700\u9876\u7ea7\u7684\u76ee\u5f55\u4e3a\u6839\u76ee\u5f55 \/\u3002 \u5176\u4ed6\u76ee\u5f55\u901a\u8fc7\u6302\u8f7d\u53ef\u4ee5\u5c06\u5b83\u4eec\u6dfb\u52a0\u5230\u6811\u4e2d\uff0c\u901a\u8fc7\u89e3\u9664\u6302\u8f7d\u53ef\u4ee5\u79fb\u9664\u5b83\u4eec\u3002 \u9996\u5148\u6211\u4eec\u9700\u8981\u5148\u77e5\u9053\u4ec0\u4e48\u662f\u7edd\u5bf9\u8def\u5f84\u4e0e\u76f8\u5bf9\u8def\u5f84\u3002 \u7edd\u5bf9\u8def\u5f84\uff1a\u8def\u5f84\u7684\u5199\u6cd5\uff0c\u7531\u6839\u76ee\u5f55 \/ \u5199\u8d77\uff0c\u4f8b\u5982\uff1a\/usr\/share\/doc \u8fd9\u4e2a\u76ee\u5f55\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-16566","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=16566"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16566\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=16566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=16566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=16566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}