Which text editor etc can reverse the order of lines from top to bottom?
I am using Linux Mint Cinnamon 17.3 Rosa.
I have a large text file containing hundreds of lines. I want to reverse their order from top to bottom. As an example, if my text file was: Lion Hippo Zebra Monkey Antelope Yeti then I want to reverse the order of these lines so that the text file is now: Yeti Antelope Monkey Zebra Hippo Lion gedit can only sort lines into alphabetical order or reverse-alphabetical order. Neither of those are what I want. As far as I recall in Windows I used to use Ted text editor to do the above. I do not understand command line stuff, so a text editor or program with a GUI is what I seek please. Thanks. |
Would something like...
Code:
tac inputfile > outputfile |
No, sorry. As I wrote above, I do not understand command lines.
|
Fair enough, your loss.
|
Quote:
He gave you the exact command to use. It couldn't be any simpler. Using Linux without the CLI is like buying a house in Miami and not going to the beach. It can be done, but you're truly missing out. Anyhow, Happy New Year! |
Quote:
You don't have to understand it, just type it with your own file names replacing inputfile and outputfile and you will have your file in reverse order. For example if your input file is named myfile.txt then: Code:
tac path/to/myfile.txt > newfile.txt You should learn to use the tools available to you. If you are not using these simple filters then you are missing out on the main reason for using GNU/Linux! |
The file I want to reverse is not only located deep within a hierarchy or tree of folders, but is on my secondary HD as well. How do I navigate to that folder in the Console please, or find out what its file path is?
Thanks |
You'd navigate with "cd" but maybe to find the file in the first place, you could use locate
|
It depends upon how your file manager and the like work but it may be as simple as finding it in the file manager then right-clicking and selecting "Open in terminal". If not then you should be able to find out the path from any application you open it in -- the full path is often listed and, if not, should be available if you look a little more into it.
Then, once in the terminal, changing directory is accomplished using the "cd" command which has autocomplete functionality so you can type things like "cd /home/grumpyscheptic/my" then tab to complete something like "my favourite files", for example. To list the contents of the current directory it's just "ls". Edit: One of many basic guides. |
Quote:
|
Quote:
|
@273 - sorry I missed your post above. :(
Quote:
1. Open your file manager and "copy" the directory the file is in - image 2. Open a terminal type "cd " <--- a space after cd 3. Right click in the terminal with your mouse and "Paste" from the menu and hit enter: Code:
01 Jan 17 @ 11:57:16 ~ 5. just "tac" it Code:
01 Jan 17 @ 12:02:21 /media/5/Documents/Text |
OFF TOPIC
Quote:
Code:
compgen -ac | sort Code:
01 Jan 17 @ 12:17:36 ~ |
Thanks, I have followed Sector11's advice and the file is now nicely reversed.
It is actually a large Comma Separated Value file, and I have asked another question about any programs that can manipulate the columns etc in .csv files. |
All times are GMT -5. The time now is 09:06 AM. |