My Bash script is running things in a folder, in alphanumerical order. But it turns out it\'s not the same order as the one I have in my Mac OS folder. So now I\'m wondering
The sort order for many commands (incl. bash
glob, ls
, sort
) is based on your current locale settings.
You can force the collation by setting the LC_COLLATE
environment variable. Setting it to C will perform a comparison on byte values.
On my system (en_US.utf8):
sh$ touch eleve
sh$ touch élève
sh$ touch Eleve
sh$ touch Élève
sh$ touch äkta
sh$ touch österreich
sh$ ls
äkta eleve Eleve élève Élève österreich pommes
sh$ LC_COLLATE=fr_FR.utf8 ls
äkta eleve Eleve élève Élève österreich pommes
sh$ LC_COLLATE=sv_SE.utf8 ls
eleve Eleve élève Élève pommes äkta österreich
sh$ LC_COLLATE=C ls
Eleve eleve pommes Élève äkta élève österreich