LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to Sort Columns of Data (descending to ascending)? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-sort-columns-of-data-descending-to-ascending-870026/)

msbstar 03-21-2011 11:59 AM

How to Sort Columns of Data (descending to ascending)?
 
Hello Everybody,

I have an ASCII file containing 3 Columns of descending data as
flollows:
.
.
.
3277.233 | 9.032167E-16 | 5.354040E-16
3276.725 | 1.825813E-15 | 7.552098E-16
3276.211 | 2.472245E-15 | 8.826818E-16
3275.699 | 2.943001E-16 | 3.192112E-16
3275.188 | 1.921011E-15 | 5.618553E-16
3274.677 | 1.089351E-15 | 4.211239E-16
.
.
.

I want to sort them in ascending order.

Does anybody know how to do it in Ubuntu 10.4.

I would be very grateful for any help.

With best regards,
Hassan

szboardstretcher 03-21-2011 12:01 PM

Code:

sort filename
If thats not what you want:
Code:

sort --reverse filename

msbstar 03-21-2011 12:04 PM

Thanks,

But how can I save it in a new file?

thanks

colucix 03-21-2011 12:04 PM

If the file is already sorted, the problem reduces to reversing the file:
Code:

tac file

szboardstretcher 03-21-2011 12:05 PM

Quote:

Originally Posted by msbstar (Post 4298218)
Thans,

But how can I save it in a new file?

thanks

Code:

sort filename > newfilename.txt

sort -r filename > newfilename.txt

tac filename > newfilename.txt


msbstar 03-21-2011 12:08 PM

Thanks Everyone for Helping.


All times are GMT -5. The time now is 12:02 PM.