Davoud Teimouri

Virtualization & Datacenter

[How To]: Linux tac Command – Usage and Examples

Linux tac Command

tac command practically is reverse version of cat command. It means, any result in cat command will be reversed by tac command.

tac is lesser known and less used command in Linux but I want to show you the command usage and some examples.

Usage and Examples

tac command has few options same as cat command, we’ll review some of its options at the below.

Example 1

Comparison cat and tac outputs. In this example, we have a file with the below content:

Now, print the file’s content by tac:

Example 2

Both tac and cat commands has separator option which one of the most important options and the command is represented by the -s switch, which separates the contents of the file based on a string or a keyword from the file.

Example 3

The most important usage of tac command is, that it can provide a great help in order to debug log files, reversing the chronological order of log contents.

Or display the last lines by tac command.

6,990 total views, 4 views today

[How To]: Linux tac Command – Usage and Examples
5 (100%) 2 Votes

Davoud Teimouri is as a professional blogger, vExpert 2015/2016/2017/2018, VCA, MCITP. This blog is started with simple posts and now, it has large following readers.

Leave a Reply

Your email address will not be published. Required fields are marked *

Teimouri.net © 2012 Frontier Theme
Read previous post:
Linux Cat Command - Create New File
[How To]: Linux Cat Command – Usage and Examples

Linux Cat Command Cat or "concatenate files and print on the standard output" is a Linux command to print file...