[SOLVED] Which text editor etc can reverse the order of lines from top to bottom?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
No, sorry. As I wrote above, I do not understand command lines.
To be fair, you should try it as it is a complete, simple, immediate answer to your question.
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
Just be sure to use a different name for the second file to prevent overwriting the original!
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!
Last edited by astrogeek; 12-31-2016 at 08:09 PM.
Reason: added example and filename caution
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?
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,585
Rep:
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".
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
Until you become comfortable with the 'CLI' you can use your file manager if you know 'where the file is'
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 ~
$ cd /media/5/Documents/Text
01 Jan 17 @ 12:02:21 /media/5/Documents/Text
$
4. now you are in the directory where the file is you want to use:
5. just "tac" it
Code:
01 Jan 17 @ 12:02:21 /media/5/Documents/Text
$ tac packages.txt > packages-rev.txt
01 Jan 17 @ 12:04:03 /media/5/Documents/Text
$
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.