Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Bash: "sort" does not sort< Next Oldest | Next Newest >
seevee Offline





Group: Members
Posts: 10
Joined: Nov. 2008
Posted: Jan. 27 2009,21:29 QUOTE

If I enter the following code to sort a file with columns separated by colons,
Code Sample
sort -t: -k 4 file.file

the result is that the file is sorted by the third field. In fact, it does not seem to matter which field I identify after the -k option. It sorts every time by the third field.

In another file with fixed length columns, I tried the code
Code Sample
sort -k 4 file.file

and the result was the same regardless of which column I sorted by.

What am I doing wrong? What other information can I provide to help identify the problem?

Thank you in advance.
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Jan. 27 2009,23:49 QUOTE

Works ok for me on this file:
Quote
a:b:i:j
1:h:c:z
n:2:3:4


Post an example of the data in your file.
Back to top
Profile PM 
seevee Offline





Group: Members
Posts: 10
Joined: Nov. 2008
Posted: Jan. 28 2009,13:37 QUOTE

The data is phone numbers, names, and dates. Example...
Quote
231:432:4550:Mooney:Albert:P:09-23-1945
231:432:5679:Ludlow:Q-Dog:G:10-15-2007

It works for me, too - in Ubuntu.

My version is DSL 4.2.4
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Jan. 28 2009,16:58 QUOTE

I take it you have loaded gnuutils.dsl?

If

$ ls -l /usr/bin/sort

shows a link to Busybox, then you are using Busybox's sort, which has a greatly reduced option set.
Back to top
Profile PM 
seevee Offline





Group: Members
Posts: 10
Joined: Nov. 2008
Posted: Jan. 28 2009,18:06 QUOTE

Awesome help! Thank you.
Back to top
Profile PM 
4 replies since Jan. 27 2009,21:29 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Bash: "sort" does not sort

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code