LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-17-2005, 11:50 PM   #1
SuperNull
LQ Newbie
 
Registered: Dec 2004
Posts: 20

Rep: Reputation: 0
Alphabetical sort wierdness


So here is the problem;

Create a directoy and add files (or directories) to it with the following names:

-bbbbb.bla
aaaaaa.bla
ccccccc.bla

Now 'ls' it.
You will see the files in the following order:

aaaaaa.bla
-bbbbb.bla
ccccccc.bla

This is NOT an alphabetical sort, as the '-' character does not belong between the 'a' and 'c' caracters.
Why is this? Can you turn this wierd feature off? Can you get a truely alphabetical sort (in the commandline AND in Konqueror)?
I know that starting a filename with a '-' is a very bad practice but the file list I want to browse is not mine nor is it maintained by me.

Thanx alot in advance!
 
Old 11-18-2005, 12:15 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
It probably depends on your locale setting. I was able to recreate the situation you described, and saw the "LC_ALL=C" message in the sort man page. Try this at a command prompt and see what you get:
Code:
$ LC_ALL=C ls
It changed the output on my end to put the dashed filename before that aaaaaa.bla filename.
 
Old 11-18-2005, 12:21 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Re: Alphabetical sort wierdness

Quote:
Originally posted by SuperNull
So here is the problem;

Create a directoy and add files (or directories) to it with the following names:

-bbbbb.bla
aaaaaa.bla
ccccccc.bla

Now 'ls' it.
You will see the files in the following order:

aaaaaa.bla
-bbbbb.bla
ccccccc.bla

Nope... I see
$ ls -1
-bbbbb.bla
aaaaaa.bla
ccccccc.bla


Cheers,
Tink
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UT2004 wierdness JediKnight2 Linux - Games 0 09-14-2004 12:50 PM
Alphabetical Listing of Text trihai44100 Linux - Software 1 03-13-2004 11:34 AM
file wierdness bdp Linux - General 3 10-06-2003 11:18 PM
bttv wierdness iscariot Linux - Hardware 2 06-16-2003 07:38 PM
X wierdness barazor Linux - General 2 12-16-2001 03:47 PM


All times are GMT -5. The time now is 04:34 AM.

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