Linux in a Nutshell, Third Edition
by Ellen Siever, Stephen Spainhour, Jessica P. Hekman, Stephen Figgins
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 -cPrint the last two blocks of bigfile:
tail -2b bigfileBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access