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
-f
option 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.
-
-c
num
Begin printing at numth byte from the end of file.
-
-b
num
Begin printing at numth block from the end of file.
-
-n
num
Start at numth line from the end of file.
-n
is 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 -20
Continually track the system log:
tail -f /var/log/system.log
Show the last 10 characters of variable name
:
echo "$name" | tail -c -10
Reverse all lines in list
:
tail -r list
Get Mac OS X in a Nutshell 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.