cat sort(1) sort floating point numbers?

Jonathan McKeown j.mckeown at ru.ac.za
Mon Oct 3 12:37:14 UTC 2011


On Monday 03 October 2011 14:05:42 Anton Shterenlikht wrote:
> I tried sorting a file with a column of floating
> point numbers (below) with sort(1) -n. However,
> the numbers seem to have been sorted by the first
> digit only.

sort -g

Due to the GNU project's obsession with info (<http://xkcd.com/912/>), you 
can't readily find this out from the manpage - but the info documentation 
available on the web for coreutils describes the difference between -g 
and -n:

[when using -n] Neither a leading ‘+’ nor exponential notation is recognized. 
To compare such strings numerically, use the --general-numeric-sort (-g) 
option.

Jonathan


More information about the freebsd-questions mailing list