Linux and Unix tail command
Delivers the last part of the file.
tail [+ number] [-l] [-b] [-c] [-r] [-f] [-c number | -n number] [file]
|This option is only recognized if it is specified first. COUNT is a decimal number optionally followed by a size letter (`b', `k', `m') as in `-c', or `l' to mean count by lines, or other option letters (`cfqv').|
|-l||Units of lines.|
|-b||Units of blocks.|
|-c||Units of bytes.|
|-r||Reverse. Copies lines from the specified starting point in the file in reverse order. The default for r is to print the entire file in reverse order.|
|-f||Follow. If the input-file is not a pipe, the program will not terminate after the line of the input-file has been copied, but will enter an endless loop, wherein it sleeps for a second and then attempts to read and copy further records from the input-file. Thus it may be used to monitor the growth of a file that is being written by some other process.|
|-c number||The number option-argument must be a decimal integer whose sign affects the location in the file, measured in bytes, to begin the copying:
The origin for counting is 1; that is, -c+1 represents the first byte of the file, -c-1 the last.
|-n number||Equivalent to -c number, except the starting location in the file is measured in lines instead of bytes. The origin for counting is 1; that is, -n+1 represents the first line of the file, -n-1 the last.|
|file||Name of the file you wish to display|
The above example would list the last 10 (default) lines of the file myfile.txt.
tail myfile.txt -n 100
The above example would list the last 100 lines in the file myfile.txt.
tail -f myfile.txt
This next example displays the last 10 lines and then update the file as new lines are being added. This is a great command to use to watch log files or logs in real-time.
tail -f access.log | grep 22.214.171.124
Finally, if you're trying to view a file such as the Apache access log file that is updated frequently you can pipe its output through the grep command to filter out only the content you want. In this above example, we're watching the access.log for any IP address of 126.96.36.199