Name
tail
Synopsis
tail [options] [file]
Prints the last ten lines of the named file. Use either
-f or -r, but not both.
Options
-
-f Don’t quit at the end of file; “follow” file as it grows. End with an INTR (usually
^C).-
-F Behaves the same as the
-foption with the exception that it checks every five seconds to see if the filename has changed. If it has, it will close the file and open the new file.-
-r Copy lines in reverse order.
-
-cnum Begin printing at numth byte from the end of file.
-
-bnum Begin printing at numth block from the end of file.
-
-nnum Start at numth line from the end of file.
-nis the default and does not need to be specified.-
[+/-] To start from the beginning of the file, use
+before num. The default is to start from the end of the file; this can also be done by using a-before num.
Examples
Show the last 20 lines containing instances of .Ah:
grep '\.Ah' file | tail -20Continually track the system log:
tail -f /var/log/system.logShow the last 10 characters of variable name:
echo "$name" | tail -c -10Reverse all lines in list:
tail -r listBecome 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