The tail
command prints the last 10 lines of a file by default.
Example:
tail filename.txt
Syntax:
tail [OPTION] [FILENAME]
Use the -n
option with a number(should be an integer) of lines to display.
Example:
tail -n 10 foo.txt
Syntax:
tail -n <~number> foo.txt
This command will display the last 10 lines of file foo.txt
.
You can also omit the n
flag, this example will also give same result as above command:
tail -10 foo.txt
It's possible to let tail output any new line added to the file you are looking into. So if a new log entry is written to the file, it will immediately be shown in your output. This can be done via --follow
or -f
as an option.
Example:
tail -f foo.txt