Unix tail command

Unix tail command

You could see last part of the file using tail command. It prints last 10 line of input files. If you give multiple file name it then it precedes with set of output with header giving file name.

  • Syntax:

tail [option]… [File]…

  • Options help:
    To see what are all options are available for tail command please use below:

$ tail –help

Examples:

  • tail test.txt – Output last 10 lines of test.txt
  • tail -f text.txt –¬†Output last 10 lines of test.txt and watch text.txt file for any updates. If any updates happens to the file it ouputs new line that are added (Important command to check log files)
  • tail test.txt -n 50 –¬†Output last 50 lines of test.txt
  • tail -f text.txt | grep Java Honk – Very useful command if you want to monitor log file in real time. Here tail monitor the text.txt file and pipes final ten lines and any new lines added. Grep command reads output and prints only lines which contains word Java Honk
  • For more information on Unix command please visit Wikipedia

Leave a Reply

Your email address will not be published. Required fields are marked *