1、tail date.log 輸出文件末尾的內容,默認10行
tail -20 date.log 輸出最後20行的內容
tail -n -20 date.log 輸出倒數第20行到文件末尾的內容
tail -n +20 date.log 輸出第20行到文件末尾的內容
tail -f date.log 實時監控文件內容增加,默認10行。
2、head date.log 輸出文件開頭的內容,默認10行
head -15 date.log 輸出開頭15行的內容
head -n +15 date.log 輸出開頭到第15行的內容
head -n -15 date.log 輸出開頭到倒數第15行的內容
3、sed -n "開始行,結束行p" 文件名
sed -n '70,75p' date.log 輸出第70行到第75行的內容
sed -n '6p;260,400p; ' 文件名 輸出第6行 和 260到400行
sed -n 5p 文件名 輸出第5行
4、more -n 每一次展示的頁數
more -n 5 date.log 每次行, 向下翻頁
more +20 date.log 從20行開始展示之後的
tail 和 head 加上 -n參數後 都代表輸出到指定行數,tail 是指定行數到結尾,head是開頭到指定行數
+數字 代表整數第幾行, -數字代表倒數第幾行。