Re: [Nolug] question about sort(1)

From: Mark A. Hershberger <mah_at_everybody.org>
Date: Tue, 09 Mar 2004 13:39:35 -0600
Message-ID: <87u10x4xoo.fsf@weblog.localhost>

Ron Johnson <ron.l.johnson@cox.net> writes:

> Why is sort(1) trying to be so clever?

It isn't being clever. It's being stupid.

What you need to do is tell it which field to sort on. Right now, it
just sees the first field and does an alphabetical sort. Even if you
tell it "-n", it'll still do an alphabetical sort since the first
non-whitespace character of each line is "f".

So, tell it to sort on the second field using a numeric sort.:

$ sort -k 2 -n your-file.txt
file 50 10-15 19:05 ./GovForum2_2003.ram
file 493 01-20 18:45 ./MD5SUMS
file 5,454 03-01 12:03 ./HP-LaserJet_1100-hpijs.ppd.gz
file 14,236 08-25 04:55 ./Analysis of Asteroid Split.pdf
file 30,227 07-26 17:07 ./EasyTables0.8.4-9.tar.bz2
file 195,294 01-18 22:09 ./FAQ_Rev05_ENG.pdf
file 203,680 05-08 15:56 ./LinuxCompilersCompatibility702.pdf
file 651,283 07-26 14:57 ./Browser282b2.tar.gz
file 3,387,062 02-21 16:56 ./24547010.pdf

$ sort --version
sort (coreutils) 5.0.91
...

Mark.

-- 
A choice between one man and a shovel, or a dozen men with teaspoons
is clear to me, and I'm sure it is clear to you also.
    -- Zimran Ahmed <http://www.winterspeak.com/>
___________________
Nolug mailing list
nolug@nolug.org
Received on 03/09/04

This archive was generated by hypermail 2.2.0 : 12/19/08 EST