You’ve been using Linux for a while, so you must have seen or used this command before: cat. It’s used to concatenate files and print on the standard output. But do you know there is another command spelled it reversed tac? tac is like cat, but print files in reverse.

Here is an example which cat could be handy. I need to print out the last login user in reverse. (By the default, it prints the last login first.)

kenno@c2 ~ ❯❯❯ last
kenno    pts/0        192.168.1.114    Sun Nov  8 11:33   still logged in
kenno    pts/0        192.168.1.114    Sat Nov  7 22:25 - 22:26  (00:00)
kenno    pts/0        192.168.1.114    Sat Nov  7 22:20 - 22:25  (00:05)
reboot   system boot  3.14.79-117      Thu Jan  1 10:00   still running
kenno    pts/0        192.168.1.114    Sat Nov  7 21:49 - 22:16  (00:27)
kenno    pts/0        192.168.1.114    Sat Nov  7 14:36 - 18:36  (03:59)
kenno    pts/0        192.168.1.114    Sat Nov  7 02:15 - 02:18  (00:02)
kenno    pts/0        192.168.1.114    Wed Nov  4 09:58 - 09:58  (00:00)
kenno    pts/0        192.168.1.114    Tue Nov  3 23:18 - 23:19  (00:00)
kenno    pts/0        192.168.1.114    Sun Nov  1 14:12 - 01:25  (11:12)

Here is the output of last command with the first login user last.

kenno@c2 ~ ❯❯❯ last | tac
wtmp begins Sun Nov  1 14:12:40 2020

kenno    pts/0        192.168.1.114    Sun Nov  1 14:12 - 01:25  (11:12)
kenno    pts/0        192.168.1.114    Tue Nov  3 23:18 - 23:19  (00:00)
kenno    pts/0        192.168.1.114    Wed Nov  4 09:58 - 09:58  (00:00)
kenno    pts/0        192.168.1.114    Sat Nov  7 02:15 - 02:18  (00:02)
kenno    pts/0        192.168.1.114    Sat Nov  7 14:36 - 18:36  (03:59)
kenno    pts/0        192.168.1.114    Sat Nov  7 21:49 - 22:16  (00:27)
reboot   system boot  3.14.79-117      Thu Jan  1 10:00   still running
kenno    pts/0        192.168.1.114    Sat Nov  7 22:20 - 22:25  (00:05)
kenno    pts/0        192.168.1.114    Sat Nov  7 22:25 - 22:26  (00:00)
kenno    pts/0        192.168.1.114    Sun Nov  8 11:33   still logged in

Reference: