|
Home > Archive > Unix Programming > November 2006 > unix sort
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| vadaman 2006-11-22, 1:39 am |
| hi,
May be this type of question has already been answered but when I
tried
searching the posts I couldn't get proper solution from them. So I
would highly appreciate if somebody can again help me out with this.
query:
In unix while sorting a particular field,the field after the separator
also gets sorted
for example
If am sorting this means
123,345
123,112
345,321
111,546
I am getting o/p like
111,546
123,112
123,345
345,321
but i don't want to sort this after the field separator,
i expect some o/p like this
111,546
123,345
123,112
345,321
could anyone please help me out with this,
thanks
sriram.
| |
| Pascal Bourguignon 2006-11-22, 7:27 am |
| "vadaman" <ssriramprasanna@gmail.com> writes:
> hi,
> May be this type of question has already been answered but when I
> tried
> searching the posts I couldn't get proper solution from them. So I
> would highly appreciate if somebody can again help me out with this.
> query:
> In unix while sorting a particular field,the field after the separator
> also gets sorted
>
> for example
> If am sorting this means
> 123,345
> 123,112
> 345,321
> 111,546
>
> I am getting o/p like
> 111,546
> 123,112
> 123,345
> 345,321
>
> but i don't want to sort this after the field separator,
> i expect some o/p like this
> 111,546
> 123,345
> 123,112
> 345,321
>
> could anyone please help me out with this,
man sort
Watch for field separator and key.
--
__Pascal Bourguignon__ http://www.informatimago.com/
NEW GRAND UNIFIED THEORY DISCLAIMER: The manufacturer may
technically be entitled to claim that this product is
ten-dimensional. However, the consumer is reminded that this
confers no legal rights above and beyond those applicable to
three-dimensional objects, since the seven new dimensions are
"rolled up" into such a small "area" that they cannot be
detected.
| |
| James Carlson 2006-11-22, 7:27 am |
| "vadaman" <ssriramprasanna@gmail.com> writes:
> but i don't want to sort this after the field separator,
> i expect some o/p like this
> 111,546
> 123,345
> 123,112
> 345,321
At least on my UNIX system, the man page for sort(1) says this in the
NOTES section:
sort does not guarantee preservation of relative line order-
ing on equal keys.
In other words, "sort -k 1,1 -t," won't necessarily do what you're
asking.
--
James Carlson, KISS Network <james.d.carlson@sun.com>
Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
| |
| Måns Rullgård 2006-11-22, 7:22 pm |
| James Carlson <james.d.carlson@sun.com> writes:
> "vadaman" <ssriramprasanna@gmail.com> writes:
>
> At least on my UNIX system, the man page for sort(1) says this in the
> NOTES section:
>
> sort does not guarantee preservation of relative line order-
> ing on equal keys.
>
> In other words, "sort -k 1,1 -t," won't necessarily do what you're
> asking.
The -s option to GNU sort is probably what the OP needs.
--
Måns Rullgård
mru@inprovide.com
|
|
|
|
|