Article 56JMH [SOLVED] Easy way to reverse lines in a text file?

[SOLVED] Easy way to reverse lines in a text file?

by
grumpyskeptic
from LinuxQuestions.org on (#56JMH)
I have a file containing, for example,

5 pears
2 grapes
7 oranges
1 banana
5 apples

I want to reverse the lines so that I get a file containing:

5 apples
1 banana
7 oranges
2 grapes
5 pears

I have tried:

tac a.txt > b.txt

which worked for another file but for this file does not change the order at all, do not know why.

The internet also suggests using tail -r myfile.txt, but the computer says it does not know what -r means.

In windows I used to use a small text editor from years ago which could do this easily but I have forgotten what it was called. It was not Metapad, which works well under Wine.

Thanks.

Edit: I think the small text editor was Ted Notepad for Windows - see https://en.wikipedia.org/wiki/TED_Notepad

I have downloaded it and will see if it works in Linux with Wine. Is there a Linux equivalent? It is described as the Swiss army penknife of text editors.latest?d=yIl2AUoC8zA latest?i=EXB6RbZQAgk:Y_HDSwUufqI:F7zBnMy latest?i=EXB6RbZQAgk:Y_HDSwUufqI:V_sGLiP latest?d=qj6IDK7rITs latest?i=EXB6RbZQAgk:Y_HDSwUufqI:gIN9vFwEXB6RbZQAgk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments