Tac - A command to print files in reverse

Probably one of the very first commands we come across while learning Linux/Unix is “cat”. It is used to concatenate multiple files and throw them all on the standard output i.e. print them on a terminal. Not many know this, but there exists a twin of cat, named “tac”, which is similar to it but does everything in reverse - kind of an “evil twin” ;).

Here is a simple example. Lets say we have a file with the following contents(this is usually what we use cat for).

[shredder12]$ cat file

line 1
line 2

now tac will do exactly the reverse

[shredder12]$ tac file

line 2
line 1

1 Comment

ArchLinuxer (not verified)
February 5th, 2011 12:26 am
Cool ! thanks :)

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.