sort command help
In a file there are two entries -->
Windows NT Windows2008 In AIX ==> sort filename > Windows NT Windows2008 In Linux the same command with the same file produces Windows2008 Windows NT Could anyone please explain...is this because the space is treated differently in AIX & LINUX during sort... Thanks for help |
Hi,
Sort uses the locale specified in the environment (the LC_ALL=xxx setting), that is probably why there is a difference in the output. Although not all sort version support it, try using AIX sort's -A option. You could also set LC_ALL to c (LC_ALL=C), but the latter may influence more then just sort!! Be careful if this is a production environment. Hope this clears things up a bit. |
I don't know about windows, but the sorting order in unix depends on the locale. Unicode sort order especially is different from the C/POSIX order. If you set your LC_COLLATE environment variable to either C or POSIX, the sorting of the above becomes the same.
Edit: Aargh, beaten by Druuna. But I can at least point out that setting LC_COLLATE only is more specific than setting LC_ALL, and won't affect the whole system. |
Not sure on the answer because on my system, a space is sorted ahead of a "2" while "Windows2008" is sorted before "Windows NT".
I tried using -t' ' to change the field separator, without any difference. The order was always this way. I took a peek at sort.c: Code:
#ifdef POSIX_UNSPECIFIED |
Thank you all for the explanations..
|
All times are GMT -5. The time now is 02:10 AM. |