The tail command
Yaser Rahmati | یاسر رحمتی
The tail
command prints the last ten lines of a file.
Example:
Syntax:
Get a specific number of lines with tail
:
tail
:Use the -n
option with a number(should be an integer) of lines to display.
This command will display the last five lines of the file myfile.txt
.
Refresh the output on any new entry in a file
It is possible to let tail
output any new line added to the file you are looking into. So, if a new line is written to the file, it will immediately be shown in your output. This can be done using the --follow
or -f
option. This is especially useful for monitoring log files.
Syntax:
Additional Flags and their Functionalities
Short Flag | Long Flag | Description |
---|---|---|
-c | --bytes=[+]NUM | Output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file |
-f | --follow[={name|descriptor}] | Output appended data as the file grows; an absent option argument means 'descriptor' |
-F | Same as --follow=name -- retry | |
-n | --lines=[+]NUM | Output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM |
Last updated