Linux vs. Unix file wildcards Linux vs. Unix file wildcards unix unix

Linux vs. Unix file wildcards


The result depends on different shell options, particularly: nocasematch nocaseglobAnd also LC_COLLATE variable (used in sort, [-], etc.)

$ shopt extglob nocasematch nocaseglobextglob         offnocasematch     offnocaseglob      off$ printf "%s\n" a A b B c C | sortaAbBcC

So [A-C] range contains b and c, but not a, also [a-c] should contain A but not C.

$ printf "%s\n" a A b B c C | LC_COLLATE=C sortABCabc

gives a different result.

$ LC_COLLATE=C ls [A-C]*

Should return expected result, this syntax sets the variable only for the new process execution (ls), but not in current shell process.

EDIT: thanks to comment, previous command is wrong because the expansion is processed before the LC_COLLATE be set, the simplest is to split into two commands.

$ export LC_COLLATE=C$ ls [A-C]*