LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Sorting data in output file (https://www.linuxquestions.org/questions/linux-general-1/sorting-data-in-output-file-354883/)

lluciano 08-19-2005 09:23 AM

Sorting data in output file
 
I need to sort lines in an output file according to numerical data in column one, as seen in the following example:

2080 /example/path/bin/file1
1219 /example/path/bin/file2
3 /example/path/bin/file3
7 /example/path/bin/file4
3 /example/path/bin/file5
2 /example/path/bin/file6
28 /example/path/bin/file7
24 /example/path/bin/file8
188 /example/path/bin/file9
40 /example/path/bin/file10

Needs to be grepped out to another output file or sorted to look like this:

2080 /example/path/bin/file1
1219 /example/path/bin/file2
188 /example/path/bin/file9
28 /example/path/bin/file7
40 /example/path/bin/file10
24 /example/path/bin/file8
7 /example/path/bin/file4
3 /example/path/bin/file3
3 /example/path/bin/file5
2 /example/path/bin/file6

It can be done easy enough by importing the data in MS Excel, but this needs to be done locally on our LINUX and HP servers. Any help would be appreciated and thanks..

Hobbletoe 08-19-2005 09:48 AM

Code:

sort -gr outputfile > new_output

lluciano 08-19-2005 10:37 AM

Thank you. Here is the equivalent for HP UX:

sort -nr out > new_out


All times are GMT -5. The time now is 11:54 AM.