Linux:tailコマンドで出力行数を指定する方法

スポンサーリンク

tailコマンドで出力行数を指定する方法

tailコマンドで出力行数を指定するには-nオプションを指定します。

 

オプションの説明

 -n, --lines=[+]NUM       output the last NUM lines, instead of the last 10;
                           or use -n +NUM to output starting with line NUM

 

-nオプションを指定した場合

$ tail -n 5 test.txt
11
12
13
14
15
$ tail -n 12 test.txt
04
05
06
07
08
09
10
11
12
13
14
15

 

-nオプションを指定しない場合(デフォルトは10行)

$ tail test.txt
06
07
08
09
10
11
12
13
14
15