4
I had created some files like knob_A.png
and knob_a.png
and my teammate on Windows said this caused problems with her app. I decided to call it knob_W.png
instead of knob_a.png
. Then I did an rsync up to our shared server. In order to clean things up I then did
rm knob_[a-d]*.png
and it removed knob_A.png
too. This is wrong as a football bat.
Neither shopt -s nocaseglob
nor shopt -u nocaseglob
causes it to behave the way I want.
How do I tell bash to make its globs be case-sensitive like in the old days?
1you might want to expand the shell example to:
LC_COLLATE=C; ls knob_[a-d]*.png
. I'm used to doing things likeLC_COLLATE=C ls knob_[a-d]*.png
which does not work, probably because that only sets the environment of the subprocess and does not affect the bash that evaluated the glob. – Mutant Bob – 2017-06-27T17:30:55.5801@MutantBob is correct: bash expands the glob before it sets LC_COLLATE but the main problem is that a simple X=Y sets a local shell variable X, which is not the same thing as an environment variable and LC_COLLATE is an environment variable. – Denis Howe – 2018-09-29T19:43:34.453
To set an environment variable temporarily for one command, say:
LC_COLLATE=C command
Note: no semicolon between the assignment and the command.
To set it for the rest of the session, say:
export LC_COLLATE=C
This will affect globs on subsequent lines. – Denis Howe – 2018-09-29T20:01:40.980