Collate this!

Turns out that when you don't LC_COLLATE=C; export LC_COLLATE, you'll eventually get bitten in the ass by the way character ranges in shell globs are treated:
$ (unset LC_COLLATE; bash)
$ touch A a B b Z z; echo [A-Z]; echo [a-z]
A b B z Z
a A b B z
In this case, my friend discovered the interesting behavior after executing 'rm [a-z]*', apparently hoping to keep files which started with uppercase letters. Whoops!

Entry first conceived on 28 December 2007, 21:24 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2024 Jeff Epler