Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-19-2009, 08:31 PM   #1
LQ Newbie
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
Question linux (gnu) sort leading blanks

Hey, smart guys, riddle me this:

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


Output on every version of linux I tried is:


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?
Old 06-19-2009, 08:53 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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 ...

Old 06-19-2009, 09:52 PM   #3
Registered: Feb 2006
Distribution: Debian Sid
Posts: 675

Rep: Reputation: 255Reputation: 255Reputation: 255
Originally Posted by Tinkster View Post
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.
# This is the POSIX Locale definition for the LC_COLLATE category.
# The order is the same as in the ASCII code set.
Old 06-21-2009, 04:51 PM   #4
LQ Newbie
Registered: Jun 2009
Posts: 2

Original Poster
Rep: Reputation: 0
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




Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I use GNU sort to sort one field in order, another in reverse? zombieite Linux - Newbie 4 04-27-2009 12:23 AM
LXer: Linux Desktop: Seven Leading Products LXer Syndicated Linux News 0 04-02-2007 04:46 PM
Is there a line limit with the sort utility? Trying to sort 130 million lines of text gruffy Linux - General 4 08-10-2006 08:40 PM
Fullscreen console apps in GNU Screen in an X term (of some sort) problems. bugmenot60 Linux - Software 6 07-21-2006 04:48 AM
Leading Linux Distributions Become LSB Certified jeremy Linux - Distributions 16 08-20-2002 05:10 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration