(1)tail:
-n æ¯æ¾ç¤ºè¡å·ï¼ç¸å½äºnlå½ä»¤ï¼ä¾åå¦ä¸ï¼
tail -100f test.log å®æ¶çæ§100è¡æ¥å¿
tail -n 10 test.log æ¥è¯¢æ¥å¿å°¾é¨æå10è¡çæ¥å¿;
tail -n +10 test.log æ¥è¯¢10è¡ä¹åçæææ¥å¿;
(2)head:
è·tailæ¯ç¸åçï¼tailæ¯çåå¤å°è¡æ¥å¿ï¼ä¾åå¦ä¸ï¼
head -n 10 test.log æ¥è¯¢æ¥å¿æ件ä¸ç头10è¡æ¥å¿;
head -n -10 test.log æ¥è¯¢æ¥å¿æ件é¤äºæå10è¡çå ¶ä»æææ¥å¿;
(3)catï¼
tacæ¯ååºæ¥çï¼æ¯catåè¯ååï¼ä¾åå¦ä¸ï¼
cat -n test.log |grep "debug" æ¥è¯¢å ³é®åçæ¥å¿
(1)cat -n test.log |grep "debug" å¾å°å ³é®æ¥å¿çè¡å·
(2)cat -n test.log |tail -n +92|head -n 20 éæ©å ³é®åæå¨çä¸é´ä¸è¡. ç¶åæ¥çè¿ä¸ªå ³é®åå10è¡åå10è¡çæ¥å¿:
tail -n +92表示æ¥è¯¢92è¡ä¹åçæ¥å¿
head -n 20 å表示å¨åé¢çæ¥è¯¢ç»æéåæ¥å20æ¡è®°å½
sed -n '/2014-12-17 16:17:20/,/2014-12-17 16:17:36/p' test.log
ç¹å«è¯´æ:ä¸é¢ç两个æ¥æå¿ é¡»æ¯æ¥å¿ä¸æå°åºæ¥çæ¥å¿,å¦åæ æï¼
å grep '2014-12-17 16:17:20' test.log æ¥ç¡®å®æ¥å¿ä¸æ¯å¦æ该 æ¶é´ç¹
(1)使ç¨moreålesså½ä»¤,
å¦ï¼ cat -n test.log |grep "debug" |more è¿æ ·å°±å页æå°äº,éè¿ç¹å»ç©ºæ ¼é®ç¿»é¡µ
(2)ä½¿ç¨ >xxx.txt å°å ¶ä¿åå°æ件ä¸,å°æ¶å¯ä»¥æä¸è¿ä¸ªæ件åæ
å¦ï¼cat -n test.log |grep "debug" >debug.txt