2

HI,

I know that cat prints the contents of the file on screen.

i never worked on linux.But i am aware that tac is the command to show the file from bottom to top.I am not even sure whether tac is on unix.Atleast on my unix box its not present. i want to know is there a simple command unix which gives the output from bottom to top?

i am expecting like below :

<command> file_name;

I know this can be done using some tools like awk,sed. but could anyone please tell me a most simple command to perform that task?

Vijay
  • 65,327
  • 90
  • 227
  • 319

4 Answers4

3

The Unix equivalent of

tac 

is

tail -r

Hope this helps

Matyas
  • 13,473
  • 3
  • 60
  • 73
1

tac : Tac is opposite to cat in the sense that the output it produces is presented in a way that the last line is displayed first, then the second last line, and so on.

enter image description here

https://www.howtoforge.com/linux-tac-command/

Amitesh Bharti
  • 14,264
  • 6
  • 62
  • 62
1

You can use tail -r

This probably should be moved to unix.stackexchange.com

rcapote
  • 1,034
  • 7
  • 19
  • 1
    I am on Lubuntu here and my `tail` does not have the `-r` option. Now I even know why: the [POSIX specification for the tail command](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tail.html) does *not* list a `-r` option, hence it must be an (unofficial?) extension (presumedly not even a GNU extension). – syntaxerror Sep 26 '14 at 00:56
0

tac is in GNU coreutils, and is presently the only single file executable that does what you want. If you don't have tac installed you'll need to use a slower alternative, like the ones outlined at How to reverse lines of a text file?

Community
  • 1
  • 1
Femi
  • 64,273
  • 8
  • 118
  • 148