Learning Bash, potential bug or total misunderstanding regarding globbing.
me@marsar-laptop:~/test$ ls [A-Z]* -dl
-rw-r--r-- 1 happyhd happyhd 0 2009-02-07 14:44 file -rw-r--r-- 1 happyhd happyhd 0 2009-02-07 14:47 File -rw-r--r-- 1 happyhd happyhd 0 2009-02-07 14:49 file5file drwxr-xr-x 4 happyhd happyhd 4096 2009-02-07 14:36 newdir me@marsar-laptop:~/test$ Why am I seeing files starting with lowercase letters here ? |
I believe globbing is, by default, case insensitive... if you want it sensitive, try "unsetopt CASE_GLOB"
|
I'm not certain, but also look at your locale settings.
|
If your shell glob matches a directory, you'll get a listing of the _contents_ of that directory. Are you sure those listed files are in your current dir?
Edit: never mind - missed the 'd' in '-dl' Dave |
Never noticed this before. Seem like a bug to me because it only happens with ranges, unless it's like that person says it has something to do with locale settings- not sure what he means though. Case sensitivity can be set with shopt command 'shopt -u nocaseglob'.
|
This does not answer your question, but just to let you know that:
Quote:
|
This is not a bug and the following solves the issue:
Code:
env LC_COLLATE=C ls -d [A-Z]* Code:
AaBbCc...XxYyZz Code:
aAbBcC...xXyYzZ Code:
ls -d [A-Z]* |
Quote:
|
Quote:
Case sensitivity works in an ASCII character set. At least that is what I read in Richard Petersen's book "Linux: The complete Reference 6th Ed." I don't think your distro (like mine also..) uses ASCII character sets but Unicode. Vas |
Quote:
for the most complete explanation ... Books are never enough Long live the community!!! Vas |
Interesting thread containing some good info.
While trying the above commands I uncovered some strange behavior: Code:
norm ~: /bin/ls -l |grep ^d Code:
norm ~: /bin/ls -ld Isn't the -d switch supposed to provide the same data as the first listing? |
Nope. Because ls without arguments refers to the current directory. If you use the -d option the content of the current directory is not listed. To me this is the expected behaviour.
Tip of the day: to run a command ignoring its alias, you can "escape" it using backslash: Code:
\ls |
Thanks for the "backslash" tip, it does save some typing.
But I'm still confused about the -d switch. Code:
norm ~: \ls -ld t* |
Glad to read all this great feedback/info - as someone wrote here :
Long live the community! My laptop is running Kubuntu and I'm suspecting that unicode and not ASCII is used. In curiousity, I ran over to the neighbour and tested her mac (bash v2.05) and the original command worked fine there. [[:upper:]] works as a charm ! Thx :) env LC_COLLATE=C ls -d [A-Z]* doesn't Btw, '' (two single quotes) can also be used to escape an alias |
Quote:
Code:
$ ls -ld /path/to/dir Code:
ls -ld /path/to/dir/tcl /path/to/dir/temp /path/to/dir/test.sh /path/to/dir/tgs_check_image.jpg |
All times are GMT -5. The time now is 08:34 AM. |