Directory listing not fully sorted

I have the following directory listing on a Debian Linux system. However, one strange thing is that the file populate.sql does not seem to be sorted with the rest.

-rw-r--r-- 1 user1 user1 10004 Jul 28 13:16 populate2.sql
-rw-r--r-- 1 user1 user1 10244 Jul 28 13:16 populate3.sql
-rw-r--r-- 1 user1 user1 10359 Jul 28 13:16 populate4.sql
-rw-r--r-- 1 user1 user1 11618 Jul 28 13:16 populate5.sql
-rw-r--r-- 1 user1 user1 11654 Jul 28 13:17 populate6.sql
-rw-r--r-- 1 user1 user1 12198 Jul 30 16:20 populate7.sql
-rw-r--r-- 1 user1 user1 12286 Aug 10 00:10 populate8.sql
-rw-r--r-- 1 user1 user1 12331 Aug 19 08:48 populate9.sql
-rw-r--r-- 1 user1 user1 12401 Aug 20 14:58 populatea.sql
-rw-r--r-- 1 user1 user1 12460 Aug 22 01:09 populateb.sql
-rw-r--r-- 1 user1 user1 12503 Aug 22 17:13 populatec.sql
-rw-r--r-- 1 user1 user1 13341 Aug 23 23:23 populated.sql
-rw-r--r-- 1 user1 user1 13414 Aug 27 23:01 populatee.sql
-rw-r--r-- 1 user1 user1 16064 Aug 31 00:03 populatef.sql
-rw-r--r-- 1 user1 user1 17529 Sep 16 15:38 populateg.sql
-rw-r--r-- 1 user1 user1 19348 Sep 19 22:50 populateh.sql
-rw-r--r-- 1 user1 user1 21033 Sep 27 20:46 populatei.sql
-rw-r--r-- 1 user1 user1 21024 Sep 28 00:02 populatej.sql
-rw-r--r-- 1 user1 user1 22505 Sep 28 22:55 populatek.sql
-rw-r--r-- 1 user1 user1 23831 Oct  5 21:24 populatel.sql
-rw-r--r-- 1 user1 user1 23665 Nov  2 22:16 populatem.sql
-rw-r--r-- 1 user1 user1 23513 Nov  4 21:53 populaten.sql
-rw-r--r-- 1 user1 user1 27191 Nov 19 14:55 populateo.sql
-rw-r--r-- 1 user1 user1 30142 Nov 28 17:51 populatep.sql
-rw-r--r-- 1 user1 user1 30853 Dec 10 14:49 populateq.sql
-rw-r--r-- 1 user1 user1 33690 Dec 11 23:43 populater.sql
-rw-r--r-- 1 user1 user1  9945 Jul 28 13:16 populate.sql
-rw-r--r-- 1 user1 user1 38696 Jan 16 22:27 populates.sql
-rw-r--r-- 1 user1 user1 38696 Jan 16 22:27 populatet.sql

At first I thought it might be because of a hidden character or something, but I can’t think of a hidden character that would come between r and s. Also, if I type vim populate.sql into the command prompt it opens the correct file which is further evidence there isn’t a strange character there.

Any ideas why populate.sql is not being sorted correctly?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

LC_COLLATE with any Unicode-aware collation, e.g. en_US.UTF-8 results in a sort order that ignores punctuation. Consequently, populate.sql sorts as populatesql after populatersql but before populatessql.

If you want to see this behavior change, try running LC_COLLATE=C ls -al, and it will be sorted in C sorting order (by specific bytes without regard to any codepoints or locales).


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x