Unix

Tail Command in Unix/Linux


  • Tail command in unix or linux system is used to print the last N lines from the file on the terminal. Tail command is especially used with log files to read the last few lines to know about the error messages. 
  • Tail prints the last 10 lines of each FILE to standard output. With more than one FILE, it precedes each set of output with a header giving the file name. If no FILE is specified, or if FILE is specified as a dash ("-"), tail reads from standard input.
The syntax of Tail command is

The options are
  • -c: Prints the last N bytes of file; With leading +, Prints th echaracters from N byte           in the file
  • -n: Prints last N lines; With leading + prints lines from the Nth line in the file
  • -f: Prints the appended lines on the terminal as the file grows
  • -q: never output header giving filenames
Examples of Tail Command
  • Command to Display last 10 lines   

Default it displays last 10 lines in a file.
  • Command to print last 'n' Bytes. 

  • Command to display last 2 lines from file  




Powered by Blogger.