[Linux-users] Sort Question

C M Reinehr cmr
Sat Aug 4 11:17:05 PDT 2007


On Saturday 04 August 2007 08:29, Ben Duncan wrote:
> Actually, you can use several of the SORT options:
>
> sort -t? +xn
>
> Where -t? is the "delimter" to use , so if you want to break the
> sort apart by colons, it would be -t:
>
> and +xn is which fields you want to use so if you want to sort
> by the second and fifth fields, use
>
> sort +2n +5n -t:
>
> which says sort on the second by NUMERIC and the fifth by numeric.
> Now if you wanted to sort the second ALPHA and the fifth numeric,
> use:
>
> sort +2 +5n -t:
>
> Hope this helps ...

But the fact remains that you still are rearranging the rows (by varying the 
sort key), not the fields within each row, which is what he is attempting to 
do.

cmr

> sean at csupport.com wrote:
> > The sort command sorts lines of text.  So, in your example, it is doing
> > exactly what you told it to do.  You need to break each line into its
> > parts and sort that.  Try something like:
>
> <SNIP>

-- 
Debian 'Etch' - Registered Linux User #241964
--------
"More laws, less justice." -- Marcus Tullius Ciceroca, 42 BC



More information about the Linux-users mailing list