Hot answers tagged

6 votes
Accepted

Why is ls sorting Chinese filenames by length?

You'll notice that among the strings of same length, there appears to be a relative order of those characters, so they're not totally treated as being equivalent. It's not like the 🧚🧛🧜 which have ...
Stéphane Chazelas's user avatar
3 votes

How to sort the list of positional parameters in POSIX sh

Probably easiest is to resort to awk which can do strcoll(), strcmp(), and number comparisons (including of floating points). To avoid reinventing the wheel, we can use the quicksort awk ...
Stéphane Chazelas's user avatar
2 votes

How to sort the list of positional parameters in POSIX sh

you need to use the shell to eval these string first, and then can sort the results, applying the same operations to the strings that get sorted, and the array of original indices. I'll illustrate ...
Marcus Müller's user avatar
2 votes

How exactly does Nautilus sort files by name?

By default, 'ls' uses the libc locale-specific sort order, the same as used by 'sort'. For all *.UTF-8 locales (except C.UTF-8), Glibc implements the Unicode Collation Algorithm (or something close to ...
u1686_grawity's user avatar
1 vote
Accepted

Display the results in an alphabetical order, independently of their case

ls is required by POSIX to sort the file names in its output according to the collating sequence in the current locale. If your system has no locale where the sort order ignores case at least in the ...
Stéphane Chazelas's user avatar
1 vote

Why is ls sorting Chinese filenames by length?

I found out where macOS stores locale files, in /usr/share/locale, and to my surprise this is how the zh_CN.UTF-8 locale is defined: % ls -la /usr/share/locale/zh_CN.UTF-8 total 8 drwxr-xr-x 8 root ...
nneonneo's user avatar
  • 1,078
1 vote

Shell script to find and copy files from a painfully large unsorted folder

Mention of File Explorer makes me wonder if you're using Windows, and perhaps then that bash is running within cygwin. If this were the case, the cygwin intermediate layer may possibly be making the ...
rivimey's user avatar
  • 216

Only top scored, non community-wiki answers of a minimum length are eligible