tac vs cat

Isaac pointed out the tac linux utility to me today. It's probably my new favorite Linux command. It's just like cat, except it outputs your text files in reverse order. Great for grepping and looking for the last X lines in a log file. Saves a lot of time of grepping through big files.

tac /var/log/maillog | grep user@domain.com | head -n 10

We also found out that in the above example the tac (or cat if you use that) quits after the head achieves its goal. Thus if you output a large file and filter it with head it will stop parsing the file when head quits (gets 10 lines). Pretty smart.



Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.145.40.121
To prevent spam please submit by clicking the kitten: