LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   linux (gnu) sort leading blanks (https://www.linuxquestions.org/questions/linux-newbie-8/linux-gnu-sort-leading-blanks-734292/)

alex_martin62 06-19-2009 08:31 PM

linux (gnu) sort leading blanks
 
Hey, smart guys, riddle me this:

Input file to the sort command with no arguments is this:

<space><space>3
<space>2
1

Output on every version of linux I tried is:

1
<space>2
<space><space>3

But on EVERY SINGLE other operating system I tried
(including OS X, AIX, Solaris, Beos, QNX, Windows and Cygwin)
the output is the same as the input unless I use the -b argument.
That is the behavior I expected. Is linux gnu sort broken?
Extensive google can't find an answer.
It seems like -b is default behavior on linux.
How do I shut off -b ?
How do I get linux sort to give me the result I want?
The LC_ALL environment variable has no effect.

Why on earth the different behavior on linux?
Sucks that my scripts would need a special case just for linux.

Any ideas?
-R

Tinkster 06-19-2009 08:53 PM

Hi, welcome to LQ!


Which version of Linux are you using, and what's your locale?



Slackware (en_US, C) shows the desired behaviour, it must be
something with the locale ...



Cheers,
Tink

norobro 06-19-2009 09:52 PM

Quote:

Originally Posted by Tinkster (Post 3580138)
Slackware (en_US, C) shows the desired behaviour, it must be
something with the locale ...

On Debian (en_US, C) & (en_US, POSIX) both work.
Quote:

LC_COLLATE
# This is the POSIX Locale definition for the LC_COLLATE category.
# The order is the same as in the ASCII code set.

alex_martin62 06-21-2009 04:51 PM

sort leading blanks
 
Thanks guys
LC_COLLATE=C gave me what I want but
LC_COLLATE=en_US did not.
I am using a pre-installed system image of Fedora 7
for colinux. None of the LC_* environment variables
were set at all. But my co-workers using the
newest RedHat out of the box got the same behaviour..
I'll have to check his env.vars tomorrow.
Hmmm... seems like linux default behavior is different
than other systems... oh well

Thanks


All times are GMT -5. The time now is 03:39 AM.