LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-21-2009, 04:17 PM   #1
shoemoodoshaloo
LQ Newbie
 
Registered: Jun 2009
Posts: 18

Rep: Reputation: 0
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?
 
Old 07-21-2009, 04:32 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
use the -n flag as per the sort manpage.
 
Old 07-21-2009, 04:46 PM   #3
chigurh8
Member
 
Registered: Jul 2009
Distribution: Ubuntu, Gentoo
Posts: 102

Rep: Reputation: 18
Code:
sort -n -k 3 SCAT_TOT_Muscle-170 > sorted
 
Old 07-21-2009, 04:52 PM   #4
shoemoodoshaloo
LQ Newbie
 
Registered: Jun 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks guys.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Doubt about numerical precision Bassy Programming 9 12-24-2008 03:11 PM
Sorting by "Number of Replies" in ascending order does not appear to work PTrenholme LQ Suggestions & Feedback 2 02-15-2008 12:59 PM
Can not create numerical directories popowich Linux - Server 18 01-27-2008 01:27 AM
Numerical keypad Craqon Linux - General 2 12-15-2004 01:42 AM
Numerical recipes in C++ marios_auth Programming 0 07-08-2004 03:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration