Linux tac

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Linux tac command

The 'tac' command is the reverse of the 'cat' command. It is also known as 'cat' backwards. It will display the file content in reverse order.

Syntax:

tac <file name>

Example:

  1. tac count  

Linux tac command

Look at the above snapshot, we have displayed the file 'count' with both the commands 'cat' and 'tac' to show the difference between the two.


To Separate The Content

The 'tac --separator' command will separate the content from the mentioned string or keyword from the rest of the file content.

Syntax:

  1. tac <file name> --separator "<string>"  

Example:

  1. tac count --separator "two"  
  2. tac count --separator "five"  
  3. tac count --separator "one"  

Linux tac separator

Look at the above snapshot, in the first example, we have separated the content of file 'count' from the string "two" to the rest of the content with the help of 'tac count --separator "two" ' command. Then separated the content from the string "five" and "one"in the next examples.