Linux: Print File / output UpSide Down
In day to day life, sometimes we need to make our file upside down. like we have long file and we want to print its content in such way that the first line become last and last line becomes first. complete UpSide Down.
Although we can do this some vim tricks, but as linux wide support for various diffrents commands. So for this as well we have one command called tac. which could print files UpSide Down. let’s see some of its examples and how we could install this command on diffrent distribution of Nix machines.
This command could install on Ubuntu and Redhat based Linux machines and could run through normal user.
In normal case, we are using cat command to print file content like below /etc/hosts file
ssirohi@jarvis:~$ cat /etc/hosts 127.0.0.1 localhost.localdomain localhost # The following lines are desirable for IPv6 capable hosts ::1 localhost.localdomain localhost ip6-localhost ip6-loopback
But in case we like to print it UpSide down
ssirohi@jarvis:~$ tac /etc/hosts ::1 localhost.localdomain localhost ip6-localhost ip6-loopback # The following lines are desirable for IPv6 capable hosts 127.0.0.1 localhost.localdomain localhost
Although we can do this manually as well. as its quit small file. but what if in case file contains long random data that has many lines. In those cases tac command would be easy method which could save lots time that couls use in some other important work.