LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sorting by numerical order (https://www.linuxquestions.org/questions/linux-newbie-8/sorting-by-numerical-order-741776/)

shoemoodoshaloo 07-21-2009 03:17 PM

Sorting by numerical order
 
Hey guys,

Quick Q. I have a three column data file with lines as such:

1455594_at 306.42 51
1424094_at 6789.066 27
1419187_at 4.776 0

I need to tell bash to order the data numerically by entries in column 3. I've used the command:

Code:

sort -k 3 SCAT_TOT_Muscle-170 > sorted
Which works; however, it gets confused a bit and sorts as such:

88, 88, 89, 9, 9, 90, 91, 92

How do I tell bash to realize that it is sorting integers and thus 9 should not come after 89?

acid_kewpie 07-21-2009 03:32 PM

use the -n flag as per the sort manpage.

chigurh8 07-21-2009 03:46 PM

Code:

sort -n -k 3 SCAT_TOT_Muscle-170 > sorted

shoemoodoshaloo 07-21-2009 03:52 PM

Thanks guys.


All times are GMT -5. The time now is 06:36 AM.