Tac

From LQWiki
Jump to navigation Jump to search

tac is the same as cat, only tac shows lines in reverse. Imagine a file foo that contains:

hello
world

tac foo will print:

world
hello

to print the characters in a line in reverse you can use rev, to print both lines and characters in reverse use

tac foo | rev


Provided by

Most (all?) Linux distributions incorporate this from the GNU Coreutils: and use its man page

 Many Linux systems, however, are using a different version.  The current author has not yet tracked this down.


Related Commands

These all relate to the output or processing of entire files

  • cat -- concatenate files into a single result.
  • nl -- output with line numbers
  • od -- dump in octal and other character representations.
  • rev -- character-reversed cat
  • base32 -- Encode in printable characters.
  • base64 -- Encode in printable characters.