1、tail -n +/-數字 檔名
2、head -n 數字 檔名
3、sed -n "開始行,結束行p" 檔名
【步驟一】cd 到要檔案所在目錄
cd到要檢視指定行數內容的檔案所在目錄,本文以specialvariable.sh檔案為例,cd /home/test/shell/
【步驟二】tail -n -數字 檔名
tail -n -數字 檔名,表示檢視檔案的最後幾行,比如檢視specialvariable.sh的最後5行,tail -n -5 specialvariable.sh
【步驟三】tail -n +數字 檔名
tail -n +數字 檔名,表示檢視檔案的某一行到最後一行,比如檢視specialvariable.sh的第3行到最後一行,tail -n +3 specialvariable.sh
【步驟四】head -n 數字 檔名
head -n 數字 檔名,表示檢視檔案前幾行的內容,比如檢視specialvariable.sh的前3行內容,head -n 3 specialvariable.sh
【步驟五】sed -n "開始行,結束行p" 檔名
sed -n "開始行,結束行p" 檔名,表示檢視檔案的開始行到結束行的內容,sed -n "5,9p" specialvariable.sh
Linux檢視檔案指定行數內容
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 實時監控...
Linux檢視檔案指定行數內容
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 實時監控...
cat命令檢視檔案指定行數
cat filename tail n 10 顯示檔案最後10行 cat filename head n 10 顯示檔案前面10行 cat filename tail n 10 從10行開始顯示,顯示10行以後的所有行 cat filename head n 50 tail n 10 顯示10行到5...