Thursday, March 21, 2013

A look at the reverse of Unix "cat"

How to look at log events with the opposite of our unix cat commands. The opposite of “Cat” is a “Dog” , but in this post was are going to look at “tac” which is the linux version of "cat", but backwards.

The linux command tac , is one of the most helpful linux command  & with regards to log parsing. And most don’t know about it,  or that it even exists.

Here’s a cat btw;

tac, allows for one to start at the ending of the page and work your way back up. It’s similar to how cat starts at the top of the file and works it’s way downward.

So let’s say you have a text.file of ip address;
[kfelix@aa1ab:~]> cat file | more
(and so on)

So If I wanted to  review the bottom of the  file and work my way back up, I could use the unix tac cmd to achieve this.

[kfelix@aa1ab:~]> tac file | more

(and so on )

So it’s the reverse of the standard unix cat. Great for stringing logged data from bottom to top, like in a systems log file. With grep and tac, you can easily find information within a text log file, from most current to past.

Note:  tac is a utility for most linux distros, it has no availability to read compressed files in the same manner of  zcat


So remember, that we have tac as an alternative to cat, and both commands are helpful with parsing logs or other files.

Ken Felix
Freelance Network/Security Engineer
kfelix a-t hyperfeed d-o-t com


  1. Why not simply using less +G 1x.txt? :)

    1. Your correct, but the jest of this post was showing the cmd tac and how it relates to cat. That's why cat was bold numerous times in this thread.

      Your less example, is doable and their's 5 different ways to skin the cat ( no pun intended )