LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Filenames are sorted in wrong order (https://www.linuxquestions.org/questions/linux-newbie-8/filenames-are-sorted-in-wrong-order-274027/)

Simoncifer 01-05-2005 02:17 AM

Filenames are sorted in wrong order
 
Hi. I just started using Mandrake 10.0 Official Edition recently, and I noticed that the filenames are sorted in a strange way: they seems to be sorted by only alphanumeric characters, and other characters are ignored.

Example, make 3 empty files "T-02", "T01", and "T03", by using
Code:

more /dev/null > T01
When I look in Konqueror, the files are in the following order:
Code:

T01
T-02
T03

That doesn't seem right to me, seems like it is ignoring the "-" character.

This behavior is not just in Konqueror, but it is systemwide. I.E., when I get the same behavior of sorting when I use "ls" in Konsole, and even a file manager program that I downloaded: Krusader.

I even tried different partitions and filesystems. I tried on FAT32, Ext3, and ReiserFS, all give me the same result.

Is there some hidden setting in some configuration file to change this??

I have been reading help and man pages, and I tried to do a search in the forum using keyword "sorted", but nothing related to this ever comes up. So, it seems like I am the only one who has this problem..... :(

I am using Mandrake 10.0 Official Edition, kernel 2.6.3, KDE 3.2 BRANCH >= 20040204.

Thanks in advance to anyone who can solve this for me.

slakmagik 01-05-2005 02:40 AM

LANG=en_US
LC_COLLATE=C

Never had an issue with it and don't know precisely how to fix it, but searching for those and like variables may point you in the direction of a solution, as that's what it sounds like - how the system is understanding how to sort things based on language/locale settings.

$ ls -1
T0-2
T01
T03

But I could be completely wrong.

Incidentally, to create an empty file
Code:

$ >empty_file
is easier.

-- Well, it is if you use bash - don't think it works in all shells. Even so 'touch empty_file' is another method.

Simoncifer 01-06-2005 02:09 AM

I used KDE to set the country and language setting. But when I type "set" in Konsole, I get the following:
Code:

LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8:en_US:en
LC_ADDRESS=en_US.UTF-8
LC_COLLATE=en_US.UTF-8

So, I guessed I included unicode support. Do you think that's what causing the problem? If so, how can I turn off unicode support?

P.S. Thanks for the tips about the command to generate an empty file.

Quote:

Originally posted by digiot
LANG=en_US
LC_COLLATE=C


slakmagik 01-06-2005 02:55 AM

Seems to be. I just did

export LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8:en_US:en LC_ADDRESS=en_US.UTF-8 LC_COLLATE=en_US.UTF-8

and screwed up my sorting just like yours. Exporting LC_COLLATE=C again fixed it.

If you export that in, um, Konsole, or whatever you use, and then try it, it should work, but you may need to log out entirely to get it to take effect everywhere. Plus, for all I know, KDE resets itself and I have no idea how to fix that.

- I went poking around and it turns out it's set in /etc/profile.d/lang.sh in Slack (and the comments also indicate that's the issue) but that wouldn't be how your system was set up, I don't think. You should still be able to put it in your personal bash configs, at least.

Simoncifer 01-07-2005 12:52 AM

It works
 
Thanks. I just added
Code:

export LC_COLLATE=C
and the filenames are in correct order again.

I don't know where to put that in, and since I couldn't find the file you mentioned (the closest one is /etc/profile.d/10lang.sh, which has the comment at the top that said "# /etc/profile.d/lang.sh - set i18n stuff", and the file look complicated with all those "[ -n xxxx]" stuffs.... yeah, I probably need to learn that stuff soon). So, I added that line of "export" command in /etc/profile and it works. Actually, computer seems a little faster..... probably just my imagination :)

Thank you so much for your help.


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