[ILUGC] 1D1C - tail

  • From: Dhanasekar <tkdhanasekar@xxxxxxxxx>
  • To: ilugc@xxxxxxxxxxxxx, kanchilug@xxxxxxxxxxxxx, ilugd@xxxxxxxxxxxxxxxxxxxx
  • Date: Thu, 23 Mar 2023 06:00:00 +0530

tail - output the last part of files
To display the last 10 lines of a file
$ tail /var/log/messages

To Display the last N lines in a file
$ tail -n 4 /var/log/messages

To Print filename header
$ tail -v example.txt
$ tail -v /var/log/messages

To Display the last n lines from multiple files
$ tail -n 4 file1.txt file2.txt
$ tail -n 4 /var/log/messages /var/log/apache2/access.log

To Save the output of tail command to a text file
$ tail -n 10 /var/log/apache2/access.log  > output.txt

To append to output.txt
$  tail -n 10 /var/log/messages >> output.txt

To monitor real-time log files
$ tail -f /var/log/messages

To use pipes
$ tail -file.txt | sort
$ tail /var/log/messages | sort
$ tail /var/log/messages | tail -n 6 | sort

To Print N number of bytes data from a file
$ tail -c 500 /var/log/messages
$ tail -c 10M /var/log/messages

To print help options
$ tail --help



regards,
T.Dhanasekar


---
Mailing List Guidelines: https://ilugc.in/mailing-list-guidelines
Web: http://ilugc.in/
Internet Relay Chat: #ilugc on libera.chat

Other related posts:

  • » [ILUGC] 1D1C - tail - Dhanasekar