Name
tail
Synopsis
tail [options] [file]
Description
Print the last 10 lines of the named file (or standard input if - is specified) on standard output.
Options
- -n[k]
Begin printing at nth item from end-of-file. k specifies the item to count: l (lines, the default), b (blocks), or c (characters).
- -k
Same as -n, but use the default count of 10.
- +n[k]
Like - n, but start at nth item from beginning of file.
- +k
Like - k, but count from beginning of file.
- -c num {bkm}, --bytes num {bkm}
Print last num bytes. An alternate blocksize may be specified:
- b
512 bytes
- k
1 kilobyte
- m
1 megabyte
- -f
Don’t quit at the end of file; “follow” file as it grows. End when user presses Ctrl-C.
- -n num, --lines num
Print last num lines.
- -q, --quiet, --silent
Suppress filename headers.
- --version
Print version information and then exit.
Examples
Show the last 20 lines containing instances of .Ah:
grep '\.Ah
'file
|tail -20
Show the last 10 characters of variable name:
echo "$name" | tail -c
Print the last two blocks of bigfile:
tail -2b bigfile
Get Linux in a Nutshell, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.