Important tail commands

Outputs the last 10 lines of the file myfile.txt. Default is 10 lines.

tail /path/to/file/myfile.log

Outputs the last 100 lines of the file myfile.txt.

tail -n 100 /path/to/file/myfile.log 

Outputs the last 10 lines of myfile.txt, and keep follow on myfile.txt for updates; Here, -f option “which stands for follow” will keep the stream going…

tail -f /path/to/file/myfile.log

Selectively keep follow a log file in real time.

tail -f /path/to/file/myfile.log | grep 24.10.160.10

Outputs the last 10 lines of myfile.txt, and keep follow on myfile.txt for updates with a sleep interval. Here, -s option is for “sleep” and specify the sleep interval

tail -f -s 5 /path/to/file/myfile.log

We can use this to in conjunction with different other commands

ps aux | sort -nk +3 | tail -5

References :

  • https://www.howtogeek.com/481766/how-to-use-the-tail-command-on-linux/

#bash, #tail