# Linux tac command

It works opposite of the ‘cat’ command. The ‘tac’ command is also called ‘cat’ backward. It helps display the content of the file in reverse order. It displays the last line of the file first and then it will print the second last line and so on. In this way, the first line will be printed at last.

### Syntax:

tac <file name>

### Example: tac count

[email protected]:~/Desktop$cat count one two three four five six seven eight nine ten [email protected]:~/Desktop$ [email protected]:~/Desktop$tac count seven eight nine ten four five six two three one [email protected]:~/Desktop$

As you can see in the above example that we have used both ‘cat’ and ‘tac’ command to display the file ‘count’ in order to show the difference between the two.

## To Separate The Content:

This ‘tac –separator’ command is used to separate the content from the entered string or keyword from the rest content of the file.

### Syntax:

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

### Example:

tac count --separator "two"   tac count --separator "five"   tac count --separator "one"   [email protected]:~/Desktop$tac count --separater "two" three four five six seven eight nine ten one [email protected]:~/Desktop$ [email protected]:~/Desktop$[email protected]:~/Desktop$ tac count --separater "five" six seven eight nine ten one two three four [email protected]:~/Desktop$[email protected]:~/Desktop$ [email protected]:~/Desktop$cat count --separater "one" two three four five six seven eight nine ten [email protected]:~/Desktop$ [email protected]:~/Desktop\$

In the above example, first we are separating string “two” from the rest of the content of file ‘count’ by using ‘tac count –separator “two” ‘ command. Then, next we are separating the rest content from the string “five” and “one” respectively.