tail Command: Tutorial & Examples
Display the last few lines of a file
tail command is a utility that is used to display the last few lines of a text file. It is often used to view log files and other files that are constantly being updated, as
it allows you to see the most recent entries in the file.
To view the last 10 lines of a file with
tail, simply type
tail followed by the name of the file:
This will display the last 10 lines of the file. You can use the
-n flag followed by a number to specify the number of lines to display:
tail -n 20 file.txt
This will display the last 20 lines of the file.
You can use the
-f flag to follow the file and display new lines as they are added to the file:
tail -f file.txt
This is useful for monitoring log files and other files that are constantly being updated.
tail is a simple and useful tool for viewing the end of text files. It is often used in combination with other commands, such as
less, to filter and process the output of those commands before viewing it in