Linux Command - tail
The Linux tail command is used to display the end of a file. It is commonly used to check the lastest changes to log files and to monitor these log files in real-time.
Display the last 10 lines of a file:
tail test1.txt
Last 5 lines of a file:
tail -n 5 test1.txt
Last 50 bytes of a file:
tail -c 50 test1.txt
Follow a file showing any updates that are appended to the end of the file:
tail -f nginx.log
Follow a file but start by displaying the last 1000 lines ( great for large log files ):
tail -n 1000 -f nginx.log
Tail two files:
tail test1.txt test2.txt
Tail two files and follow changes to both at the same time ( totally works ):
tail -f test1.txt test2.txt
Note:
- use “-v” to add a header
- use “-q” to suppress headers