Linux commands are essential tools for any user, system administrator, or developer working. Whether you are a beginner or an experienced user, understanding and mastering the power of Linux commands can greatly enhance your productivity and efficiency in managing and troubleshooting Linux systems. Many powerful and obscure commands can make working with the Linux command line a lot easier.
Let’s take a look at a relatively obscure command – tac. While the cat command is quite commonly used for displaying the contents of files as they are, the tac command in Linux is the reverse of the cat command. Which means it will list the file contents in the reverse order.Â
Here is how to use it:
Consider a file whose contents are listed using the cat command.
When you use the tac command, the contents of this file are displayed in the reverse order.Â
tac filename
Note that the tac command reverses the lines, while the rev command reverses the characters of lines.
You may be wondering where this tac command can be useful. It can greatly simplify parsing through logs and configuration files with timestamps.Â
Use the tac command to display the contents of such files in reverse order, which would mean listing them from the latest timestamp to the oldest or vice versa.
As with all Linux commands, you can consult the man page for tac too:
man tac
This is a useful yet uncommon Linux command, but it is very effective in reversing file contents.Â
Do try it out.