Pagina 1 di 1

[A-Z]* case sensitive?

Inviato: dom 26 ago 2012, 17:09
da ZeroUno
Ho fatto uno script su slackware ed ora lo sto facendo girare SENZA MODIFICHE su centos.
Ad un certo punto lo script mi fallisce.

Mi accorgo che al momento che faccio

ls [A-Z]*
lui mi va a matchare, su centos, anche i file che iniziano con lettere minuscole.

Perchè? e come lo risolvo?

Re: [A-Z]* case sensitive?

Inviato: dom 26 ago 2012, 17:22
da ZeroUno
ls [ABCDEFGHIJKLMNOPQRSTUVWXYZ]*

funziona, ma che differenza c'è?

Re: [A-Z]* case sensitive?

Inviato: dom 26 ago 2012, 17:49
da targzeta
Potrebbe essere la stessa direfferenza che esiste tra le classi di carattere e il range di caratteri. Guarda cosa dice il man di grep a riguardo:
man grep ha scritto: Within a bracket expression, a range expression consists of two characters separated by a hyphen. It matches any single character that sorts between the two
characters, inclusive, using the locale's collating sequence and character set. For example, in the default C locale, [a-d] is equivalent to [abcd]. Many locales
sort characters in dictionary order, and in these locales [a-d] is typically not equivalent to [abcd]; it might be equivalent to [aBbCcDd], for example. To obtain
the traditional interpretation of bracket expressions, you can use the C locale by setting the LC_ALL environment variable to the value C.
Emanuele

Re: [A-Z]* case sensitive?

Inviato: dom 26 ago 2012, 20:23
da ZeroUno
sospettavo qualcosa del genere.

insomma tocca stare anche attenti alle variabili di ambiente prima di fare ls. uffa.

su centos LC_COLLATE non è settata di default. E se su slackware faccio unset LC_COLLATE da in effetti lo stesso comportamento.