Bill Watson wrote:
Ok, maybe I missed a memo 5-10 years ago, but why does
# ls [A-Z]*

A listing of files that *start* with a capital letter, followed by anything. The "[A-Z]* is being expanded by the shell (bash, in my case) and is just simple shell pattern matching (not regex).

And
# ls | grep [A-Z]

A listing of all files that *contain* a capital letter anywhere in the name. The [A-Z] is being passed to grep as a basic regex.

give different results (the filenames are either upper or lower case - not
mixed in the example).

Why does [A-Z] mean AbBcCdD in ls while it means ABCD in grep?
Is there any ls command switch that sorts in 01..89AB..YZab..yz order
instead of aAbBcC order? Would this cause the first ls command to work if
there was? (work defined as give me the uppercase filenames)

Sorting is defined by locale settings. Trying setting LC_ALL=C

$ LC_ALL=C ls -1
1
A
a

I grew up on Motorola unix and SCO and they sorted listings in ascii value
order. Migrating that to linux caught this unanticipated feature.

From the footnote of "info ls":

If you use a non-POSIX locale (e.g., by setting `LC_ALL' to
`en_US'), then `ls' may produce output that is sorted differently than
you're accustomed to.  In that case, set the `LC_ALL' environment
variable to `C'.

--
/* Wes Hardin */

_______________________________________________
rhelv5-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/rhelv5-list

Reply via email to