最後更新: 2021-03-08
Opts
-f, --follow=Name
output appended data as the file grows
-F
相當於 "-f /path/to/file --retry"
--retry keep trying to open a file if it is inaccessible
-s, --sleep-interval=N
with -f, sleep for approximately N seconds (default 1.0) between iterations.
---
-n / -n K
Output the last n / K lines, instead of the default last 10 ( -10 / -n 10)
use "-n +K" format to output lines starting with the Kth
tail -n +1 # 由第一行開始, 亦即係全要
tail -n +2 # 由第二行開始, 亦即係略過 header (第一行)
應用
# 不要頭 4 行及尾 3 行
cat list.txt | tail -n +5 | head -n -3 | less
Notes
head -n, --lines=[-]NUM
print the first NUM lines instead of the first 10;
with the leading '-', print all but the last NUM lines of each file
tail -n, --lines=[+]NUM
output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM