[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mon, 22 Jan 2007 17:11:10 -0800
> I'm not sure if what I found is a bug but it doesn't make much sense to
> me. I'm using sort to sort numerically 2 files that differ after the third
> column and I find that the sorting depends on this difference.
> I show you below and example of this behaviour. I use > to show the comand
> on the comand line. I start sorting numerically a file with 4 columns
> called "tirame1", saving the result into "tirame2". Then I copy only the 3
> first columns into a new file called "tirame3". If I sort numerically this
> last file and save it as "tirame4", I find differences between "tirame3"
> and "tirame4". Why?
You specified -n on the command line, telling it to sort numerically, but
you didn't specify what fields you're sorting on, so it was trying to
interpret each whole line as a number.
Try it this way:
> sort -n -k1,1 -k2,2 -k3,3 -k4,4 tirame > tirame2
...and it will sort numericaly on field 1, field 2, field 3 and field 4,
in that order, and you'll get saner results.
- sort, Violeta Gonzalez Perez, 2007/01/22
- Re: sort,
Evan Hunt <=
- Re: sort, Matthew Woehlke, 2007/01/22