{"id":8889,"date":"2025-04-18T17:02:27","date_gmt":"2025-04-18T09:02:27","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/8889.html"},"modified":"2025-04-18T17:02:27","modified_gmt":"2025-04-18T09:02:27","slug":"%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%b8%b8%e7%94%a8%e6%96%87%e6%9c%ac%e5%91%bd%e4%bb%a4cat-tacmore-lesshead-tail-%e6%96%87%e6%9c%ac%e5%86%85%e5%ae%b9%e5%a4%84%e7%90%86%e5%91%bd%e4%bb%a4cut-sort-uniq-wc-jo","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/8889.html","title":{"rendered":"\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b"},"content":{"rendered":"<h2>\u4e00\u3001\u6587\u672c\u67e5\u770b\u5e38\u7528\u516d\u4e2a\u547d\u4ee4cat\/tac,more\/less,head\/tail\u5e38\u7528\u9009\u9879<\/h2>\n<h3>1: \u67e5\u770b\u6574\u4e2a\u6587\u4ef6:\u6b63\u5411\u67e5\u770b\/\u53cd\u5411\u67e5\u770b<\/h3>\n<p>cat:cat\u547d\u4ee4\u7528\u4e8e\u67e5\u770b\u6587\u4ef6&#xff0c;\u6587\u4ef6\u8f83\u5927\u65f6&#xff0c;\u6587\u672c\u5728\u5c4f\u5e55\u4e0a\u8fc5\u901f\u95ea\u8fc7&#xff08;\u6eda\u5c4f&#xff09;&#xff0c;\u7528\u6237\u4f1a\u770b\u4e0d\u6e05\u6240\u663e\u793a\u7684\u5185\u5bb9\u3002\u4e3a\u4e86\u63a7\u5236\u6eda\u5c4f&#xff0c;\u53ef\u4ee5\u6309Ctrl&#043;S\u952e&#xff0c;\u505c\u6b62\u6eda\u5c4f&#xff1b;\u6309Ctrl&#043;Q\u952e\u53ef\u4ee5\u6062\u590d\u6eda\u5c4f,\u4e00\u822c\u7528more\u7b49\u547d\u4ee4\u5206\u5c4f\u663e\u793a.\u53e6\u5916cat\u8fd8\u975e\u5e38\u9002\u7528\u4e8e\u6587\u4ef6\u5185\u5bb9\u5408\u5e76\u5904\u7406\u3002 \u00a0 \u00a0 -n\u6216-number&#xff1a;\u5e26\u884c\u7f16\u53f7\u663e\u793a&#xff1b;\u00a0 \u00a0 \u00a0 -b\u6216&#8211;number-nonblank&#xff1a;\u548c-n\u76f8\u4f3c&#xff0c;\u4f46\u5bf9\u4e8e\u7a7a\u767d\u884c\u4e0d\u7f16\u53f7 \u00a0 \u00a0 -s\u6216&#8211;squeeze-blank&#xff1a;\u5f53\u9047\u5230\u6709\u8fde\u7eed\u4e24\u884c\u4ee5\u4e0a\u7684\u7a7a\u767d\u884c&#xff0c;\u5c31\u4ee3\u6362\u4e3a\u4e00\u884c\u7684\u7a7a\u767d\u884c \u00a0 \u00a0 -A&#xff1a;\u663e\u793a\u4e0d\u53ef\u6253\u5370\u5b57\u7b26&#xff0c;\u884c\u5c3e\u663e\u793a\u201c$\u201d\u3002&#8211;show-all \u7b49\u4ef7\u4e8e -vET\u3002 \u00a0 \u00a0 -E \u663e\u793a\u884c\u7ed3\u675f\u7b26&#xff08;LINUX\u6bcf\u884c\u7684\u7ed3\u675f\u7b26\u4e3a$\u7b26&#xff0c;WINDOWS\u4e3a$\u7b26\u548c\u6362\u884c\u7b26&#xff08;\u56de\u8f66\u7b26&#xff09; \u00a0 \u00a0 -T, &#8211;show-tabs \u5c06\u8df3 \u5b57\u7b26\u663e\u793a\u4e3a ^I \u00a0 \u00a0 -v, &#8211;show-nonprinting \u4f7f\u7528 ^ \u548c M- \u5f15\u7528&#xff0c;\u9664\u4e86 LFD \u548c TAB \u4e4b\u5916,\u4e2d\u6587\u4e0d\u4f1a\u4ee5\u4e2d\u6587\u5b57\u7b26\u4e32\u73b0\u5b9e\u3002 \u00a0 \u00a0 -e&#xff1a;\u7b49\u4ef7\u4e8e&#034;-vE&#034;\u9009\u9879&#xff1b; \u00a0 \u00a0 -t&#xff1a;\u7b49\u4ef7\u4e8e&#034;-vT&#034;\u9009\u9879&#xff1b; tac:tac\u547d\u4ee4\u7528\u4e8e\u53cd\u5e8f\u663e\u793acat\u7684\u5185\u5bb9&#xff0c;\u4ece\u884c\u5012\u5e8f\u8f93\u51fa\u6587\u4ef6\u5185\u5bb9.\u9002\u7528\u4e8e\u4e00\u4e9b\u6309\u5927\u5c0f\u6392\u5e8f\u7684\u6570\u636e\u53cd\u5e8f\u663e\u793a\u3002 \u00a0 \u00a0 -b, &#8211;before \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 attach the separator before instead of after \u00a0 \u00a0 -r, &#8211;regex \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0interpret the separator as a regular expression \u00a0 \u00a0 -s, &#8211;separator&#061;STRING \u00a0 \u6307\u5b9a\u5355\u5143\u5206\u9694\u7b26&#xff0c;\u800c\u4e0d\u662f\u6362\u884c<\/p>\n<h3>2:\u5206\u5c4f\u67e5\u770b\u6587\u4ef6\u5185\u5bb9<\/h3>\n<p>more:\u7a7a\u683c\u5411\u540e\u7ffb&#xff0c;\u53ef\u4f7f\u7528b\u5411\u524d\u7ffb&#xff0c;h\u663e\u793a\u5e2e\u52a9,q\u9000\u51fa,\u7ffb\u5230\u6700\u540e\u4e5f\u4f1a\u81ea\u52a8\u9000\u51fa \u00a0 \u00a0 \u00a0\u8f93\u5165\u659c\u7ebf\u7b26 \/&#xff1a;\u63a5\u7740\u8f93\u5165\u4e00\u4e2a\u6a21\u5f0f&#xff0c;\u53ef\u4ee5\u5728\u6587\u672c\u4e2d\u5bfb\u627e\u4e0b\u4e00\u4e2a\u76f8\u5339\u914d\u7684\u6a21\u5f0f\u3002\u4f46\u65e0\u67e5\u627e\u5230\u663e\u793a less:\u7a7a\u683c\u5411\u540e&#xff0c;b\u5411\u524d&#xff0c;pageUP\/pageDown\u4e5f\u884c\u3002\u7ffb\u5230\u6700\u540e\u4e0d\u81ea\u52a8\u9000\u51fa(\u8981\u81ea\u52a8\u9000\u51fa\u5e26\u4e0a-e\u9009\u9879)&#xff0c;q\u547d\u4ee4\u9000\u51fa\u3002less\u4e5f\u53ef\u4ee5\/\u67e5\u627e \u00a0 \u00a0 \u00a0-l&#xff1a;\u641c\u7d22\u65f6\u5ffd\u7565\u5927\u5c0f\u5199\u7684\u5dee\u5f02&#xff1b; -N&#xff1a;\u884c\u9996\u663e\u793a\u884c\u53f7&#xff1b;\u00a0 \u00a0 \u00a0 \u00a0-s&#xff1a;\u5c06\u8fde\u7eed\u591a\u4e2a\u7a7a\u884c\u538b\u7f29\u6210\u4e00\u884c\u663e\u793a&#xff1b; -S&#xff1a;\u5728\u5355\u884c\u663e\u793a\u8f83\u957f\u7684\u5185\u5bb9&#xff0c;\u800c\u4e0d\u6362\u884c\u663e\u793a&#xff1b; \u00a0 \u00a0 \u00a0-x&lt;\u6570\u5b57&gt;&#xff1a;\u5c06TAB\u5b57\u7b26\u663e\u793a\u4e3a\u6307\u5b9a\u4e2a\u6570\u7684\u7a7a\u683c\u5b57\u7b26\u3002<\/p>\n<h3>3:\u67e5\u770b\u9875\u9762\u7684\u90e8\u5206\u5185\u5bb9<\/h3>\n<p>head:\u7528\u4e8e\u663e\u793a\u6587\u4ef6\u7684\u5f00\u5934\u7684\u5185\u5bb9,\u4e3b\u8981\u9009\u9879:-n ,-c \u00a0 \u00a0 header -n [\u884c\u6570] filepath \u663e\u793a\u5f00\u5934\u51e0\u884c&#xff0c;\u9ed8\u8ba4\u4e3a10\u884c\u3002 \u00a0 \u00a0 header -c \u5b57\u7b26\u4e32 filepath \u663e\u793a\u5f00\u5934\u51e0\u4e2a\u5b57\u7b26&#xff0c;\u5fc5\u987b\u6307\u5b9a\u6570\u5b57 tail:\u67e5\u770b\u6587\u4ef6\u672b\u5c3e\u7684\u5185\u5bb9&#xff0c;\u4e3b\u8981\u4f7f\u7528\u9009\u9879:-n ,-c\u548chead\u4e00\u6837\u3002<\/p>\n<p>tail -f \u5982\u679c\u8981\u67e5\u770b\u4e00\u4e2a\u5f53\u524d\u8fd8\u672a\u521b\u5efa\u7684\u6587\u4ef6\u65f6\u53ef\u4f7f\u7528&#xff1a; tail -fq s1.log &#8211;retry \u53ef\u4ee5\u7b49\u5f85\u6587\u4ef6\u521b\u5efa.<\/p>\n<p>tail\u548chead\u6307\u5b9a-n\u9009\u9879\u540e&#xff0c;\u6570\u5b57\u53c2\u6570\u503c\u8fd8\u53ef\u4ee5\u8fd8&#043;\/-\u7b26\u53f7&#xff0c;<\/p>\n<p>tail\u5e26&#043;\u53f7\u8868\u793a\u4ece\u7b2c\u51e0\u884c\u5f00\u59cb\u4e00\u76f4\u53d6\u5230\u6700\u540e\u4e00\u884c&#xff0c;\u5e26-\u53f7\u8868\u793a\u53d6\u6700\u540e\u51e0\u884c&#xff0c;\u5b9e\u9645\u5c31\u548c\u4e0d\u5e26&#043;\/-\u53f7\u4e00\u6837\u3002\u5982tail -n &#043;2\u5c31\u662f\u6307\u4ece\u7b2c\u4e8c\u884c\u5f00\u59cb\u4e00\u76f4\u5230\u6700\u540e\u4e00\u884c\u3002<\/p>\n<p>head\u5e26-\u53f7\u8868\u793a\u4ece\u5934\u4e00\u76f4\u53d6\u5230\u6700\u540e\u7b2c\u51e0\u884c&#xff0c;\u5e26&#043;\u53f7\u8868\u793a\u53d6\u524d\u9762\u51e0\u884c&#xff0c;\u5373\u548c\u4e0d\u5e26\u7b26\u53f7\u4e00\u6837\u3002<\/p>\n<p>\u6240\u4ee5\u8bb0\u4f4fhead\u53ef\u4ee5\u4f7f\u7528\u51cf\u53f7&#xff0c;tail\u53ef\u4ee5\u4f7f\u7528\u52a0\u53f7\u3002<\/p>\n<h2>\u4e8c\u3001\u6587\u672c\u5185\u5bb9\u5e38\u7528\u7b80\u5355\u5904\u7406\u547d\u4ee4<\/h2>\n<p>\u00a0 \u6587\u672c\u5185\u5bb9\u5e38\u7528\u7b80\u5355\u5904\u7406\u547d\u4ee4\u5e38\u7528\u7684\u6709\u526a\u53d6cut,\u6392\u5e8fsort,\u53bb\u91cduniq,\u7edf\u8ba1wc,\u8fde\u63a5join,\u66ff\u6362tr<\/p>\n<h3>1. Cut\u547d\u4ee4<\/h3>\n<p>\u00a0 cut&#xff1a;-d\u6307\u5b9a\u5206\u5272\u7b26\u53f7&#xff0c;-f\u53d6\u7b2c\u51e0\u5217,\u53ef\u4ee5\u662f1-3\u62161,3\u3002-b &#xff1a;\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u8fdb\u884c\u5206\u5272\u3002-c &#xff1a;\u4ee5\u5b57\u7b26\u4e3a\u5355\u4f4d\u8fdb\u884c\u5206\u5272\u3002cut\u662f\u4e00\u4e2a\u622a\u53d6\u547d\u4ee4&#xff0c;\u975e\u5e38\u9002\u5408\u4e8e\u5904\u7406\u4ee5\u4e00\u4e2a\u5b57\u7b26\u95f4\u9694\u7684\u6587\u672c\u5185\u5bb9\u3002\u5c31\u662f\u5c06\u4e00\u6bb5\u6570\u636e\u7ecf\u8fc7\u5206\u6790&#xff0c;cut\u9009\u53d6\u4fe1\u606f\u901a\u5e38\u662f\u9488\u5bf9\u201c\u884c\u201d\u6765\u8fdb\u884c\u5206\u6790\u7684\u3002cut\u7684\u6240\u6709\u9009\u9879\u53c2\u6570<\/p>\n<p>-b &#xff1a;#\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u5206\u5272\u3002<br \/>\n-c &#xff1a;#\u4ee5\u5b57\u7b26\u4e3a\u5355\u4f4d\u5206\u5272\u3002<br \/>\n-d &#xff1a;#\u81ea\u5b9a\u4e49\u5206\u9694\u7b26&#xff0c;\u9ed8\u8ba4\u4e3a\u5236\u8868\u7b26\u3002<br \/>\n-f &#xff1a;#\u4e0e-d\u4e00\u8d77\u4f7f\u7528&#xff0c;\u6307\u5b9a\u663e\u793a\u54ea\u4e2a\u533a\u57df&#xff0c;\u5982-f1,-f1-3,-f3-,-f-3\u7b49\u3002<br \/>\n-s : #\u4e0e-d\u4e00\u8d77\u4f7f\u7528&#xff0c;\u5982\u679c\u52a0\u4e0a-s\u8868\u793a\u53ea\u663e\u793a\u6709\u5206\u9694\u7b26\u7684\u884c<br \/>\n-n &#xff1a;#\u53d6\u6d88\u5206\u5272\u591a\u5b57\u8282\u5b57\u7b26\u3002\u4ec5\u548c -b \u6807\u5fd7\u4e00\u8d77\u4f7f\u7528\u3002\u5bf9\u591a\u5b57\u8282\u5b57\u7b26\u5982\u679c\u5b57\u7b26\u7684\u6700\u540e\u4e00\u4e2a\u5b57\u8282\u3002 <\/p>\n<p>cut\u547d\u4ee4\u7684\u8bed\u6cd5\u5f62\u5f0f&#xff1a;<\/p>\n<p>cut  [-bn] [file] \u6216 cut [-c] [file]  \u6216  cut [-df] [file] <\/p>\n<p>\u00a0cut\u5e38\u89c1\u7684\u7528\u6cd5\u5982\u4e0b\u793a\u4f8b&#xff1a;<\/p>\n<p>[root&#064;kermit ~]# cat pass<br \/>\ndatabase:mysql:sqlserver:oracle<br \/>\ncountry:\u4e2d\u56fd:\u7f8e\u56fd:other<br \/>\n\u884c\u4e1a:\u4e92\u8054\u7f51:\u91d1\u878d<br \/>\n\/home\/ftpuser:\/bin\/bash<br \/>\nhello;yes;test<br \/>\n[root&#064;kermit ~]# cut -d: -f2 pass<br \/>\nmysql<br \/>\n\u4e2d\u56fd<br \/>\n\u4e92\u8054\u7f51<br \/>\n\/bin\/bash<br \/>\nhello;yes;test<br \/>\n[root&#064;kermit ~]# cut -d: -f1-2 pass  #\u8fd8\u662f\u4ee5\u539f\u5206\u9694\u7b26\u8fdb\u884c\u8fde\u63a5<br \/>\ndatabase:mysql<br \/>\ncountry:\u4e2d\u56fd<br \/>\n\u884c\u4e1a:\u4e92\u8054\u7f51<br \/>\n\/home\/ftpuser:\/bin\/bash<br \/>\nhello;yes;test<br \/>\n[root&#064;kermit ~]# cut -sd: -f1-2 pass #\u6b64\u5904\u52a0\u4e86-s\u6700\u540e\u4e00\u884c\u5c31\u4e0d\u663e\u793a&#xff0c;\u56e0\u4e3a\u5b83\u6ca1\u6709:\u7b26\u53f7<br \/>\ndatabase:mysql<br \/>\ncountry:\u4e2d\u56fd<br \/>\n\u884c\u4e1a:\u4e92\u8054\u7f51<br \/>\n\/home\/ftpuser:\/bin\/bash<br \/>\n[root&#064;kermit ~]# cut -b 1-2 pass #\u6c49\u5b57\u90a3\u884c\u76f4\u63a5\u6ca1\u6709\u663e\u793a<br \/>\nda<br \/>\nco<br \/>\n\/h<br \/>\nhe<br \/>\n[root&#064;kermit ~]# cut -nb 1-2 pass #-b\u9009\u9879\u4e2d\u6587\u5c31\u4e0d\u597d\u7528&#xff0c;\u56e0\u4e3a\u4e00\u4e2a\u6c49\u5b57\u5360\u75283\u4e2a\u5b57\u8282(utf8)\u3002<br \/>\nda<br \/>\nco<\/p>\n<p>\/h<br \/>\nhe<br \/>\n[root&#064;kermit ~]# cut -nb 1-3 pass #\u6b64\u65f6\u80fd\u5b8c\u6574\u663e\u793a\u6c49\u5b57<br \/>\ndat<br \/>\ncou<br \/>\n\u884c<br \/>\n\/ho<br \/>\nhel<br \/>\n[root&#064;kermit ~]# cut -c 1 pass   #\u4ee5\u5b57\u7b26\u6570\u6765\u663e\u793a&#xff0c;\u5c31\u4e0d\u7528\u8003\u8651\u6c49\u5b57\u95ee\u9898\u4e86\u3002<br \/>\nd<br \/>\nc<br \/>\n\u884c<br \/>\n\/<br \/>\nh<br \/>\n[root&#064;kermit ~]#  <\/p>\n<p>\u00a0\u961f\u6b64\u4e4b\u5916&#xff0c;cut\u8fd8\u80fd\u63a5\u53d7\u6807\u51c6\u8f93\u5165&#xff0c;\u547d\u4ee4\u793a\u4f8b&#xff1a;\u00a0cut -d: -f1 &#8211; \u8981\u9000\u51fa\u6807\u51c6\u8f93\u5165&#xff0c;\u53ea\u9700ctrl&#043;d\u5373\u53ef\u3002<\/p>\n<h3>2. Sort \u547d\u4ee4\u00a0<\/h3>\n<p>sort:\u9ed8\u8ba4\u4ee5\u9996\u5b57\u7b26\u6392\u5e8f(\u800c\u4e14\u662f\u4ee5\u5b57\u7b26\u4e32\u6392\u5e8f)&#xff0c;\u5e38\u7528\u9009\u9879\u6709\u5982\u4e0b&#xff1a;<\/p>\n<p>\u00a0 \u00a0 -n\u8868\u793a\u4ee5\u6570\u503c\u5927\u5c0f\u6392\u5e8f&#xff0c; \u00a0 \u00a0 -t\u4ee5\u4ec0\u4e48\u5206\u5f00&#xff0c; \u00a0 \u00a0 -k\u4ee5\u7b2c\u51e0\u5217\u6392\u5e8f&#xff0c;-k\u540e\u9762\u8ddf\u6570\u5b57\u8868\u793a\u4ee5\u7b2c\u51e0\u5217\u6392\u5e8f&#xff0c;\u540c\u65f6\u8fd8\u53ef\u4f7f\u75281.2\u8fd9\u79cd\u5c0f\u6570\u8868\u793a\u4ee5\u7b2c1\u5217\u7684\u7b2c2\u4e2a\u5b57\u7b26\u6392\u5e8f\u3002 \u00a0 \u00a0 -r\u964d\u5e8f \u00a0 \u00a0 -u\u6392\u5e8f\u65f6\u76f8\u540c\u7684\u884c\u53ea\u663e\u793a\u4e00\u6b21&#xff0c;\u5373unique. \u00a0 \u00a0 -f\u6392\u5e8f\u65f6\u5ffd\u7565\u5b57\u7b26\u5927\u5c0f\u5199\u3002 \u00a0 \u00a0 -d&#xff1a;\u6392\u5e8f\u65f6&#xff0c;\u5904\u7406\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u53ca\u7a7a\u683c\u5b57\u7b26\u5916&#xff0c;\u5ffd\u7565\u5176\u4ed6\u7684\u5b57\u7b26&#xff1b;\u00a0 \u00a0 \u00a0 -b&#xff1a;\u5ffd\u7565\u6bcf\u884c\u524d\u9762\u5f00\u59cb\u51fa\u7684\u7a7a\u683c\u5b57\u7b26&#xff1b; \u9ed8\u8ba4\u5c31\u4f7f\u7528\u4e86\u6b64\u9879 \u00a0 \u00a0 -c&#xff1a;\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5df2\u7ecf\u6309\u7167\u987a\u5e8f\u6392\u5e8f&#xff1b;\u4f1a\u8fd4\u56de\u54ea\u4e00\u884c\u6ca1\u6709\u6b63\u786e\u6392\u5e8f\u3002 \u00a0 \u00a0 -i&#xff1a;\u6392\u5e8f\u65f6&#xff0c;\u9664\u4e86040\u81f3176\u4e4b\u95f4\u7684ASCII\u5b57\u7b26\u5916&#xff0c;\u5ffd\u7565\u5176\u4ed6\u7684\u5b57\u7b26&#xff1b;\u00a0 \u00a0 \u00a0 -m&#xff1a;\u5c06\u51e0\u4e2a\u6392\u5e8f\u53f7\u7684\u6587\u4ef6\u8fdb\u884c\u5408\u5e76&#xff1b;\u00a0 \u00a0 \u00a0 -M&#xff1a;\u5c06\u524d\u97623\u4e2a\u5b57\u6bcd\u4f9d\u7167\u6708\u4efd\u7684\u7f29\u5199\u8fdb\u884c\u6392\u5e8f&#xff1b; \u00a0 \u00a0 \u00a0 -o&lt;\u8f93\u51fa\u6587\u4ef6&gt;&#xff1a;\u5c06\u6392\u5e8f\u540e\u7684\u7ed3\u679c\u5b58\u5165\u5236\u5b9a\u7684\u6587\u4ef6 \u00a0 \u00a0 -t&lt;\u5206\u9694\u5b57\u7b26&gt;&#xff1a;\u6307\u5b9a\u6392\u5e8f\u65f6\u6240\u7528\u7684\u680f\u4f4d\u5206\u9694\u5b57\u7b26 \u00a0 \u00a0 &#043;&lt;\u8d77\u59cb\u680f\u4f4d&gt;-&lt;\u7ed3\u675f\u680f\u4f4d&gt;&#xff1a;\u4ee5\u6307\u5b9a\u7684\u680f\u4f4d\u6765\u6392\u5e8f&#xff0c;\u8303\u56f4\u7531\u8d77\u59cb\u680f\u4f4d\u5230\u7ed3\u675f\u680f\u4f4d\u7684\u524d\u4e00\u680f\u4f4d\u3002<\/p>\n<h3>3.Uniq \u547d\u4ee4<\/h3>\n<p>uniq\u53ea\u628a\u76f8\u90bb\u7684\u91cd\u590d\u884c\u8fc7\u6ee4&#xff0c;\u56e0\u6b64\u6267\u884cuniq\u524d\u9700\u8981\u6267\u884c\u4e00\u4e0bsort&#xff0c;\u5176\u9009\u9879\u5982\u4e0b&#xff1a;<\/p>\n<p>\u00a0 \u00a0 -d\u53ea\u663e\u793a\u91cd\u590d\u7684\u884c(\u53ea\u4e00\u884c)&#xff0c; \u00a0 \u00a0 -D\u663e\u793a\u6240\u6709\u91cd\u590d\u884c \u00a0 \u00a0 -c\u663e\u793a\u91cd\u590d\u7684\u6b21\u6570&#xff0c;uniq\u53ef\u4ee5\u663e\u793a\u91cd\u590d\u884c&#xff0c;\u884c\u53f7,\u5728\u6bcf\u5217\u65c1\u8fb9\u663e\u793a\u8be5\u884c\u91cd\u590d\u51fa\u73b0\u7684\u6b21\u6570&#xff1b; \u00a0 \u00a0 -d\u6216&#8211;repeated&#xff1a;\u4ec5\u663e\u793a\u91cd\u590d\u51fa\u73b0\u7684\u884c\u5217&#xff1b; \u00a0 \u00a0 -f&lt;\u680f\u4f4d&gt;\u6216&#8211;skip-fields&#061;&lt;\u680f\u4f4d&gt;&#xff1a;\u5ffd\u7565\u6bd4\u8f83\u6307\u5b9a\u7684\u680f\u4f4d&#xff1b; \u00a0 \u00a0 -s&lt;\u5b57\u7b26\u4f4d\u7f6e&gt;\u6216&#8211;skip-chars&#061;&lt;\u5b57\u7b26\u4f4d\u7f6e&gt;&#xff1a;\u5ffd\u7565\u6bd4\u8f83\u6307\u5b9a\u7684\u5b57\u7b26&#xff1b; \u00a0 \u00a0 -u\u6216\u2014\u2014unique&#xff1a;\u4ec5\u663e\u793a\u51fa\u4e00\u6b21\u7684\u884c\u5217&#xff1b; \u00a0 \u00a0 -w&lt;\u5b57\u7b26\u4f4d\u7f6e&gt;\u6216&#8211;check-chars&#061;&lt;\u5b57\u7b26\u4f4d\u7f6e&gt;&#xff1a;\u6307\u5b9a\u8981\u6bd4\u8f83\u7684\u5b57\u7b26<\/p>\n<h3>4.Join \u547d\u4ee4<\/h3>\n<p>\u00a0 \u00a0 Join \u547d\u4ee4\u8fde\u63a5\u4e24\u4e2a\u6587\u4ef6\u6587\u4ef6&#xff0c;\u4f46\u524d\u63d0\u662f\u6709\u76f8\u540c\u610f\u4e49\u7684\u5217&#xff0c;\u00a0\u00a0\u00a0\u00a0join\u547d\u4ee4\u4e00\u822c\u4e0d\u5e38\u7528&#xff0c;\u4e0d\u8fc7\u6bcf\u4e2a\u547d\u4ee4\u80af\u5b9a\u90fd\u6709\u5b83\u7684\u610f\u4e49&#xff0c;\u4e86\u89e3\u4e86\u4e00\u4e0b\u53d1\u73b0\u4e5f\u633a\u6709\u610f\u601d&#xff0c;\u4e5f\u8bb8\u54ea\u5929\u5c31\u771f\u80fd\u7528\u5230\u3002join\u9002\u5408\u5c06\u4e00\u4e9b\u7ed3\u6784\u5316\u7684\u6587\u672c\u6570\u636e\u8fdb\u884c\u6574\u5408\u3002\u524d\u63d0\u4ed6\u4eec\u90fd\u662f\u591a\u5217\u6570\u636e&#xff0c;\u5176\u4e2d\u591a\u4e2a\u6587\u4ef6\u4e2d\u6709\u4e00\u4e2a\u610f\u4e49\u76f8\u540c\u4e14\u6570\u636e\u4e0d\u91cd\u590d\u7684\u5217&#xff0c;\u6bd4\u5982\u4e00\u4e2a\u6587\u4ef6\u5b58\u653e\u7740\u5b66\u751f\u7684\u5b66\u53f7\u548c\u59d3\u540d&#xff0c;\u53e6\u4e00\u4e2a\u6587\u4ef6\u5b58\u653e\u7740\u5b66\u53f7\u548c\u9ad8\u8003\u5206\u6570&#xff0c;\u8fd9\u65f6\u5c06\u8fd9\u4e24\u4e2a\u6587\u672c\u6587\u4ef6\u5408\u5728\u4e00\u8d77\u5c31\u53ef\u4ee5\u4f7f\u7528join\u65b9\u6cd5\u3002\u793a\u4f8b\u5982\u4e0b&#xff1a;<\/p>\n<p>[root&#064;123 ~]# cat a.txt     #\u5217\u51faa.txt\u6587\u4ef6\u5185\u5bb9<br \/>\n1   \u6625\u5929<br \/>\n2   \u590f\u5929<br \/>\n3   \u79cb\u5929<br \/>\n4   \u51ac\u5929<br \/>\n5   \u51ac\u53bb\u6625\u6765<br \/>\n[root&#064;123 ~]# cat b.txt     #\u5217\u51fab.txt\u6587\u4ef6\u5185\u5bb9<br \/>\n0   \u6625\u6765\u5929<br \/>\n1   \u6696<br \/>\n2   \u70ed<br \/>\n3   \u51c9<br \/>\n4   \u51b7<br \/>\n[root&#064;123 ~]# join a.txt b.txt  #\u4f7f\u7528join\u76f8\u8fde&#xff0c;\u5c31\u50cfmysql\u7684\u8fde\u63a5\u4e00\u6837&#xff0c;\u9ed8\u8ba4\u662f\u5185\u8fde\u63a5&#xff0c;<br \/>\n1 \u6625\u5929 \u6696<br \/>\n2 \u590f\u5929 \u70ed<br \/>\n3 \u79cb\u5929 \u51c9<br \/>\n4 \u51ac\u5929 \u51b7<br \/>\n[root&#064;123 ~]# join -o 1.1 1.2 1.3 a.txt b.txt    #\u53ef\u4ee5\u6307\u5b9a\u8f93\u51fa\u54ea\u4e9b\u5217\u5e76\u6307\u5b9a\u6392\u5e8f&#xff0c;1\/2\u6587\u4ef6\u4ee3\u8868\u6587\u4ef61\/2\u7684\u7b2c\u51e0\u5217\u3002<br \/>\n1 \u6625\u5929<br \/>\n2 \u590f\u5929<br \/>\n3 \u79cb\u5929<br \/>\n4 \u51ac\u5929<br \/>\n[root&#064;123 ~]# join -o 1.1 1.2 2.2 a.txt b.txt<br \/>\n1 \u6625\u5929 \u6696<br \/>\n2 \u590f\u5929 \u70ed<br \/>\n3 \u79cb\u5929 \u51c9<br \/>\n4 \u51ac\u5929 \u51b7<br \/>\n[root&#064;123 ~]# join -o 1.1 2.2 1.2 a.txt b.txt<br \/>\n1 \u6696 \u6625\u5929<br \/>\n2 \u70ed \u590f\u5929<br \/>\n3 \u51c9 \u79cb\u5929<br \/>\n4 \u51b7 \u51ac\u5929<br \/>\n[root&#064;123 ~]# join -a1 a.txt b.txt  #\u5c31\u50cfmysql\u7684\u5de6\u8fde\u63a5&#xff0c;\u53f3\u8fde\u63a5\u4e00\u6837\u3002<br \/>\n1 \u6625\u5929 \u6696<br \/>\n2 \u590f\u5929 \u70ed<br \/>\n3 \u79cb\u5929 \u51c9<br \/>\n4 \u51ac\u5929 \u51b7<br \/>\n5 \u51ac\u53bb\u6625\u6765<br \/>\n[root&#064;123 ~]# join -a2 a.txt b.txt<br \/>\n0 \u6625\u6765\u5929<br \/>\n1 \u6625\u5929 \u6696<br \/>\n2 \u590f\u5929 \u70ed<br \/>\n3 \u79cb\u5929 \u51c9<br \/>\n4 \u51ac\u5929 \u51b7<br \/>\n[root&#064;123 ~]# join -a1 -a2 a.txt b.txt<br \/>\n0 \u6625\u6765\u5929<br \/>\n1 \u6625\u5929 \u6696<br \/>\n2 \u590f\u5929 \u70ed<br \/>\n3 \u79cb\u5929 \u51c9<br \/>\n4 \u51ac\u5929 \u51b7<br \/>\n5 \u51ac\u53bb\u6625\u6765<br \/>\n[root&#064;123 ~]# cat a.txt b.txt   #\u628a\u6587\u4ef6\u5185\u5bb9\u6362\u4e86\u4e00\u4e0b\u3002\u539f\u6765\u662f\u5236\u8868\u5206\u5f00&#xff0c;\u6539\u6210&#061;\u53f7<br \/>\n1&#061;\u6625\u5929<br \/>\n2&#061;\u590f\u5929<br \/>\n3&#061;\u79cb\u5929<br \/>\n4&#061;\u51ac\u5929<\/p>\n<p>1&#061;\u6696<br \/>\n2&#061;\u70ed<br \/>\n3&#061;\u51c9<br \/>\n4&#061;\u51b7<br \/>\n[root&#064;123 ~]# join  a.txt b.txt         #\u76f4\u63a5\u8fde\u63a5\u65f6\u62a5\u9519&#xff0c;\u627e\u4e0d\u5230\u6709\u5e8f\u6570\u636e<br \/>\njoin: file 1 is not in sorted order<br \/>\n[root&#064;123 ~]# join -t &#039;&#061;&#039; a.txt b.txt   #\u6307\u5b9a\u4ee5&#061;\u5206\u5f00\u624d\u53ef\u4ee5\u7ed3\u5408\u5728\u4e00\u8d77\u3002<br \/>\n1&#061;\u6625\u5929&#061;\u6696<br \/>\n2&#061;\u590f\u5929&#061;\u70ed<br \/>\n3&#061;\u79cb\u5929&#061;\u51c9<br \/>\n4&#061;\u51ac\u5929&#061;\u51b7<br \/>\n[root&#064;123 ~]# cat a.txt     #\u4fee\u6539\u6587\u4ef6\u5185\u5bb9&#xff0c;\u4f7f\u5f97b.txt\u4e2d\u7684ID\u6570\u5b57\u4e0d\u5728\u7b2c\u4e00\u5217<br \/>\n1&#061;\u6625\u5929<br \/>\n2&#061;\u590f\u5929<br \/>\n3&#061;\u79cb\u5929<br \/>\n4&#061;\u51ac\u5929<br \/>\n[root&#064;123 ~]# cat b.txt<br \/>\n\u6696&#061;1<br \/>\n\u70ed&#061;2<br \/>\n\u51c9&#061;3<br \/>\n\u51b7&#061;4<br \/>\n[root&#064;123 ~]# join -1 1 -2 2 -t &#039;&#061;&#039; a.txt b.txt     #\u8fde\u63a5\u65f6\u6307\u5b9a\u6bcf\u4e2a\u6587\u4ef6\u4f7f\u7528\u54ea\u5217\u5224\u65ad\u76f8\u7b49<br \/>\n1&#061;\u6625\u5929&#061;\u6696<br \/>\n2&#061;\u590f\u5929&#061;\u70ed<br \/>\n3&#061;\u79cb\u5929&#061;\u51c9<br \/>\n4&#061;\u51ac\u5929&#061;\u51b7<br \/>\n[root&#064;123 ~]# join -1 2 -2 1 -t &#039;&#061;&#039; b.txt a.txt<br \/>\n1&#061;\u6696&#061;\u6625\u5929<br \/>\n2&#061;\u70ed&#061;\u590f\u5929<br \/>\n3&#061;\u51c9&#061;\u79cb\u5929<br \/>\n4&#061;\u51b7&#061;\u51ac\u5929<br \/>\n[root&#064;123 ~]# join -1 2 -2 1  -o 1.2 2.2 1.1 -t &#039;&#061;&#039; b.txt a.txt  #\u6307\u5b9a\u8fde\u63a5\u54ea\u4e9b\u5217\u548c\u987a\u5e8f<br \/>\n1&#061;\u6625\u5929&#061;\u6696<br \/>\n2&#061;\u590f\u5929&#061;\u70ed<br \/>\n3&#061;\u79cb\u5929&#061;\u51c9<br \/>\n4&#061;\u51ac\u5929&#061;\u51b7<br \/>\n[root&#064;123 ~]#  <\/p>\n<h3>5.wc \u547d\u4ee4<\/h3>\n<p>\u00a0 wc\u547d\u4ee4\u6bd4\u8f83\u7b80\u5355&#xff0c;\u5c31\u662f\u7edf\u8ba1&#xff1a;\u9ed8\u8ba4\u7ed3\u679c&#xff0c;\u884c&#xff0c;\u5355\u8bcd\u6570&#xff0c;\u5b57\u8282\u6570\u3002\u5373\u5bf9\u5e94\u9009\u9879-l,-w,-c,-m\u5b57\u7b26\u6570&#xff0c;-L\u6700\u957f\u7684\u4e00\u884c\u5305\u542b\u591a\u5c11\u5b57\u7b26\u3002wc\u547d\u4ee4\u53ef\u4ee5\u63a5\u6536\u6807\u51c6\u8f93\u5165(\u6307\u5b9a\u7ed3\u675f\u7b26EOF&#xff0c;\u5982\u4e0b:)<\/p>\n<p>[root&#064;123 ~]wc &lt;&lt;  EOF<br \/>\n&gt; aaa<br \/>\n&gt; bbbb<br \/>\n&gt; ccccc dd<br \/>\n&gt; EOF<br \/>\n 3  4 18<br \/>\n[root&#064;123 ~] <\/p>\n<h3>6.tr \u547d\u4ee4<\/h3>\n<p>tr \u547d\u4ee4\u7528\u4e8e\u5b57\u7b26\u4e32\u66ff\u6362&#xff0c;\u6ce8\u610ftr\u662f\u5bf9\u9010\u5b57\u7b26\u8fdb\u884c\u64cd\u4f5c\u7684\u3002\u5e38\u7528\u9009\u9879\u6709\u5982\u4e0b&#xff1a;<\/p>\n<p>\u00a0 \u00a0 -d\u6216\u2014\u2014delete&#xff1a;\u5220\u9664\u6240\u6709\u5c5e\u4e8e\u7b2c\u4e00\u5b57\u7b26\u96c6\u7684\u5b57\u7b26&#xff1b; \u00a0 \u00a0 -c\u6216\u2014\u2014complerment&#xff1a;\u53d6\u4ee3\u6240\u6709\u4e0d\u5c5e\u4e8e\u7b2c\u4e00\u5b57\u7b26\u96c6\u7684\u5b57\u7b26&#xff1b;\u53ef\u4ee5\u8ba4\u4e3a\u548c-d\u76f8\u53cd\u3002 \u00a0 \u00a0 -s\u6216&#8211;squeeze-repeats&#xff1a;\u628a\u8fde\u7eed\u91cd\u590d\u7684\u5b57\u7b26\u4ee5\u4e00\u4e2a\u5b57\u7b26\u8868\u793a&#xff1b; \u00a0 \u00a0 -t\u6216&#8211;truncate-set1&#xff1a;\u5148\u5220\u9664\u7b2c\u4e00\u5b57\u7b26\u96c6,\u4ee5\u7b2c\u4e8c\u5b57\u7b26\u96c6\u66ff\u6362&#xff0c;\u4f4d\u6570\u4e0d\u5bf9\u4ee5\u7b2c\u4e8c\u5b57\u7b26\u96c6\u6700\u540e\u7684\u8865\u4f4d\u3002<\/p>\n<p>tr\u547d\u4ee4\u4f7f\u7528\u793a\u4f8b\u5982\u4e0b&#xff1a;<\/p>\n<p>[root&#064;123 ~]# echo &#039;KEEP smiling!&#039; | tr &#039;a-z&#039; &#039;A-Z&#039;    #\u81ea\u5b9a\u4e49\u96c6\u5408&#xff0c;\u4e5f\u53ef\u4ee5\u4f7f\u7528&#039;rewqr{]&#039;<br \/>\nKEEP SMILING!<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling!&#039; | tr &#039;Es&#039; &#039;1&#039;<br \/>\nK11P 1miling!<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling!&#039; | tr &#039;KEEP&#039; &#039;1&#039;  #tr\u5e76\u4e0d\u4f1a\u628aKEEP\u5f53\u4e00\u4e2a\u5b57\u7b26\u4e32\u6765\u8fdb\u884c\u6574\u4f53\u66ff\u6362<br \/>\n1111 smiling!<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling!&#039; | tr -s &#039;a-z&#039; &#039;A-Z&#039;  #-s\u628a\u76f8\u540c\u7684E\u7528\u4e00\u4e2a\u66ff\u6362\u3002<br \/>\nKEP SMILING!<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling!&#039; | tr -d &#039;h-l&#039;    #-d\u8fdb\u884c\u5220\u9664<br \/>\nKEEP smng!<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling!&#039; | tr -d E<br \/>\nKP smiling!<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling!&#039; | tr -s &#039;e&#039;<br \/>\nKEEP smiling!<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling!&#039; | tr -s &#039;E&#039;<br \/>\nKEP smiling!<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling! 1234 ok&#039; | tr -d -c &#039;0-9&#039; #-c\u9009\u9879\u5220\u9664\u4e0d\u5728-c\u6307\u5b9a\u7684\u8303\u56f4\u5185\u7684\u5b57\u7b26&#xff0c;\u633a\u6709\u7528\u3002\u5373-c\u53cd\u8f6c\u5b57\u7b26\u8303\u56f4\u3002<br \/>\n1234[root&#064;123 ~]#<br \/>\n[root&#064;123 ~]#<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling! 1234 ok&#039; | tr -d -c &#039;0-9\\\\n&#039; #\u6ce8\u610f\u533a\u522b&#xff0c;\u4e0d\u628a\u6362\u884c\u5220\u9664\u3002<br \/>\n1234<br \/>\n[root&#064;123 ~]# echo &#039;KEEP smiling! 1234 ok&#039; | tr -t &#039;KEP&#039; &#039;EP&#039;   #-t\u7684\u4f5c\u7528\u793a\u4f8b<br \/>\nEPPP smiling! 1234 ok <\/p>\n<p>\u5176\u5b83tr\u53ef\u4ee5\u76f4\u63a5\u5bfc\u5165\u6587\u4ef6&#xff0c;\u4f7f\u7528&lt;\u53f7\u5bfc\u5165&#xff0c;\u5982cat a A &lt; \/etc\/passwd&#xff0c;\u5bfc\u5165\u6587\u4ef6 \u8fd8\u53ef\u4ee5\u5220\u9664\u6587\u4ef6\u7684\u7a7a\u683c&#xff1a;cat a.txt | tr -d &#039; &#039; \u5982\u8981\u53bb\u6389\u6362\u884c\u518d\u52a0\u4e0a\u53cd\u659c\u7ebfn\u5373\u53ef\u3002 tr\u5728\u5b57\u7b26\u66ff\u6362\u4e0a&#xff0c;\u529f\u80fd\u5f88\u5f3a\u5927&#xff0c;\u8fd8\u6709\u5f88\u591a\u5b57\u7b26\u7c7b\u53ef\u4ee5\u4f7f\u7528&#xff0c;\u5982\u4e0b\u5217\u8868&#xff1a;<\/p>\n<p>SETs are specified as strings of characters.  Most represent themselves.<br \/>\nInterpreted sequences are:<\/p>\n<p>  \\\\NNN            character with octal value NNN (1 to 3 octal digits)<br \/>\n  \\\\\\\\              backslash<br \/>\n  \\\\a              audible BEL<br \/>\n  \\\\b              backspace<br \/>\n  \\\\f              form feed<br \/>\n  \\\\n              new line<br \/>\n  \\\\r              return<br \/>\n  \\\\t              horizontal tab<br \/>\n  \\\\v              vertical tab<br \/>\n  CHAR1-CHAR2     all characters from CHAR1 to CHAR2 in ascending order<br \/>\n  [CHAR*]         in SET2, copies of CHAR until length of SET1<br \/>\n  [CHAR*REPEAT]   REPEAT copies of CHAR, REPEAT octal if starting with 0<br \/>\n  [:alnum:]       all letters and digits #\u5b57\u6bcd\u548c\u6570\u5b57<br \/>\n  [:alpha:]       all letters   #\u5b57\u6bcd<br \/>\n  [:blank:]       all horizontal whitespace #\u7a7a\u767d<br \/>\n  [:cntrl:]       all control characters #\u63a7\u5236&#xff08;\u975e\u6253\u5370&#xff09;\u5b57\u7b26<br \/>\n  [:digit:]       all digits    #\u6570\u5b57<br \/>\n  [:graph:]       all printable characters, not including space #\u56fe\u5f62\u5b57\u7b26<br \/>\n  [:lower:]       all lower case letters    #\u5c0f\u5199\u5b57\u6bcd<br \/>\n  [:print:]       all printable characters, including space #\u53ef\u6253\u5370\u5b57\u7b26<br \/>\n  [:punct:]       all punctuation characters    #\u6807\u70b9\u7b26\u53f7<br \/>\n  [:space:]       all horizontal or vertical whitespace #\u7a7a\u767d\u5b57\u7b26<br \/>\n  [:upper:]       all upper case letters    #\u5927\u5199\u5b57\u6bcd<br \/>\n  [:xdigit:]      all hexadecimal digits    #\u5341\u516d\u8fdb\u5236\u5b57\u7b26<br \/>\n  [&#061;CHAR&#061;]        all characters which are equivalent to CHAR <\/p>\n<p>\u00a0\u5173\u4e8e\u4e0a\u9762\u7684\u4e24\u4e2a\u7a7a\u767d&#xff0c;\u5982\u4e0b\u64cd\u4f5c\u793a\u4f8b&#xff0c;\u540e\u8005\u4f1a\u5c06\u6362\u884c\u53bb\u6389(\u5373\u5305\u542b\u5782\u76f4\u65b9\u5411\u7684\u7a7a\u767d\u5b57\u7b26)&#xff0c;\u8fd9\u4e5f\u5c31\u662f\u8fd9\u4e24\u4e2a\u5b57\u7b26\u96c6\u7684\u533a\u522b\u3002<\/p>\n<p>#cat a.txt | tr -d &#039;[:blank:]&#039;  \u548c cat a.txt | tr -d &#039;[:space:]&#039;  <\/p>\n<p>\u00a0 \u00a0 \u5728\u5b57\u7b26\u66ff\u6362\u4e0a\u8fd8\u6709\u4e00\u4e2a\u5f88\u5f3a\u5927\u7684\u547d\u4ee4sed,\u548ctr\u4e0d\u540c\u7684\u662f&#xff0c;sed\u4e5f\u662f\u6309\u884c\u64cd\u4f5c\u7684\u3002\u800ctr\u662f\u6309\u5b57\u7b26\u64cd\u4f5c\u7684\u3002sed\u53bb\u9664\u6bcf\u884c\u524d\u7a7a\u683c\u793a\u4f8b&#xff1a;<\/p>\n<p>sed &#039;s\/^[[:space:]]*\/\/&#039; a.txt<\/p>\n<p>#\u6216\u8005&#xff1a;<\/p>\n<p>sed &#039;s\/ \/\/g&#039; a.txt\u00a0<\/p>\n<h2>\u4e09\u3001\u5e38\u7528\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u547d\u4ee4<\/h2>\n<p>\u7edf\u8ba1\u76ee\u5f55\u6587\u4ef6\u4e2a\u6570: ls | wc -l \u7edf\u8ba1\u76ee\u5f55\u53ca\u5b50\u76ee\u5f55\u603b\u6587\u4ef6\u4e2a\u6570&#xff1a;ls -R | wc -l \u641c\u7d22\u6587\u4ef6\u540d\u5e76\u7edf\u8ba1\u4e2a\u6570&#xff1a; ls | grep &#039;.lua&#039; | wc -l \u7edf\u8ba1\u6587\u4ef6\u5939\u7684\u5927\u5c0f&#xff1a; du -s \u6216\u8005 du -sh \u5c06\u6587\u4ef6\u5939\u4e0b\u76ee\u5f55\u548c\u6587\u4ef6\u6309\u5927\u5c0f\u6392\u5e8f&#xff1a;du -sk * | sort -n \u5982\u5f53\u524d\u6587\u4ef6\u5927\u5c0f\u5dee\u4e0d\u591a\u53ef\u4f7f\u7528du -sh \u67e5\u770b\u67d0\u6587\u4ef6\u6216\u76ee\u5f55\u5927\u5c0f: du -sh name\u00a0 \u7edf\u8ba1\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u6587\u4ef6\u7684\u4e2a\u6570: ls -l |grep &#034;^-&#034;|wc -l \u7edf\u8ba1\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u76ee\u5f55\u7684\u4e2a\u6570: ls -l |grep &#034;^d&#034;|wc -l \u7edf\u8ba1\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u6587\u4ef6\u7684\u4e2a\u6570&#xff0c;\u5305\u62ec\u5b50\u6587\u4ef6\u5939\u91cc\u7684:ls -lR|grep &#034;^-&#034;|wc -l \u7edf\u8ba1\u6587\u4ef6\u5939\u4e0b\u76ee\u5f55\u7684\u4e2a\u6570&#xff0c;\u5305\u62ec\u5b50\u6587\u4ef6\u5939\u91cc\u7684:ls -lR|grep &#034;^d&#034;|wc -l<\/p>\n<h2>\u56db\u3001\u5e38\u7528\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4&#xff1a;<\/h2>\n<p>1.CPU\u5360\u7528\u6700\u591a\u7684\u524d10\u4e2a\u8fdb\u7a0b&#xff1a; ps auxw|head -1;ps auxw|sort -rn -k3|head -10<\/p>\n<p>2.\u5185\u5b58\u6d88\u8017\u6700\u591a\u7684\u524d10\u4e2a\u8fdb\u7a0b ps auxw|head -1;ps auxw|sort -rn -k4|head -10<\/p>\n<p>3.\u865a\u62df\u5185\u5b58\u4f7f\u7528\u6700\u591a\u7684\u524d10\u4e2a\u8fdb\u7a0b ps auxw|head -1;ps auxw|sort -rn -k5|head -10<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb4.2k\u6b21\uff0c\u70b9\u8d5e84\u6b21\uff0c\u6536\u85cf88\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86Linux\u7cfb\u7edf\u4e2d\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\u3001\u6587\u672c\u5185\u5bb9\u5904\u7406\uff08\u5982cut\u3001sort\u3001uniq\u3001wc\u548cjoin\uff09\u3001\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u4ee5\u53ca\u670d\u52a1\u5668\u6027\u80fd\u76d1\u63a7\uff08\u5982CPU\u3001\u5185\u5b58\u548c\u865a\u62df\u5185\u5b58\u5360\u7528\uff09\u7684\u5e38\u7528\u547d\u4ee4\u53ca\u5176\u9009\u9879\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[59,58,236,237,238,239],"topic":[],"class_list":{"0":"post-8889","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-server","7":"tag-centos","8":"tag-linux","10":"tag-237","11":"tag-238","12":"tag-239"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/8889.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb4.2k\u6b21\uff0c\u70b9\u8d5e84\u6b21\uff0c\u6536\u85cf88\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86Linux\u7cfb\u7edf\u4e2d\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\u3001\u6587\u672c\u5185\u5bb9\u5904\u7406\uff08\u5982cut\u3001sort\u3001uniq\u3001wc\u548cjoin\uff09\u3001\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u4ee5\u53ca\u670d\u52a1\u5668\u6027\u80fd\u76d1\u63a7\uff08\u5982CPU\u3001\u5185\u5b58\u548c\u865a\u62df\u5185\u5b58\u5360\u7528\uff09\u7684\u5e38\u7528\u547d\u4ee4\u53ca\u5176\u9009\u9879\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/8889.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T09:02:27+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/8889.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/8889.html\",\"name\":\"\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T09:02:27+00:00\",\"dateModified\":\"2025-04-18T09:02:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/8889.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/8889.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/8889.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/8889.html","og_locale":"zh_CN","og_type":"article","og_title":"\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb4.2k\u6b21\uff0c\u70b9\u8d5e84\u6b21\uff0c\u6536\u85cf88\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86Linux\u7cfb\u7edf\u4e2d\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\u3001\u6587\u672c\u5185\u5bb9\u5904\u7406\uff08\u5982cut\u3001sort\u3001uniq\u3001wc\u548cjoin\uff09\u3001\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u4ee5\u53ca\u670d\u52a1\u5668\u6027\u80fd\u76d1\u63a7\uff08\u5982CPU\u3001\u5185\u5b58\u548c\u865a\u62df\u5185\u5b58\u5360\u7528\uff09\u7684\u5e38\u7528\u547d\u4ee4\u53ca\u5176\u9009\u9879\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/8889.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T09:02:27+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/8889.html","url":"https:\/\/www.wsisp.com\/helps\/8889.html","name":"\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T09:02:27+00:00","dateModified":"2025-04-18T09:02:27+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/8889.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/8889.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/8889.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u670d\u52a1\u5668\u5e38\u7528\u6587\u672c\u547d\u4ee4cat\/tac,more\/less,head\/tail \u6587\u672c\u5185\u5bb9\u5904\u7406\u547d\u4ee4cut\/sort\/uniq\/wc\/join\/tr \u4ee5\u53ca\u6587\u4ef6\u76ee\u5f55\u7edf\u8ba1\u3001\u670d\u52a1\u5668\u5f00\u9500\u7edf\u8ba1\u547d\u4ee4\u8be6\u89e3\u53ca\u793a\u4f8b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/8889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=8889"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/8889\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=8889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=8889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=8889"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=8889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}