Are you really doing globbing, i.e. wildcard expansion? For example, suppose that you have a directory called Foobar
. Then
cd foobar
doesn't do globbing, because there is no wildcard character. When you specify a file name exactly, it's up to the application to decide what to do with it, and since unix file names are case sensitive, the application will not open a file called Foobar
if you tell it to open a file called foobar
.
On the other hand,
cd foo*
will change to the Foobar
directory (assuming there is no other match), if you've set the nocaseglob
option.
You can make completion case-insensitive too. Put set completion-ignore-case on
in ~/.inputrc
, or
bind 'set completion-ignore-case on'
in ~/.bashrc
. Then after entering cd foo
and pressing Tab, the shell will complete Foobar
.
The -false
idea is the key, IMHO. I'm just adding to it:
find . -false $(echo "-o -name *."{sh,pl,sql})
You just quote everything to make bash repeat the whole pattern, including -o -name
, and then "break" the grouping made by the quoting by returning it from a subshell. The problem with this approach is that quotes in the pattern won't work.
EDIT: See Michał Šrajer's comment for another pitfall of this solution. Note that you can't just put a backslash before the star: the command substitution returns either a *
, which will get expanded, or a \*
, which will get passed as-is to find (!). At least, that's how my local bash works.
This is the best I can do:
(GLOBIGNORE='*:.*'; find . \( -false $(echo "-o -name *."{sh,pl,sql,xml}) \) -print)
Good luck :)
Btw, if you are not going to add more parameters to find
, of course just use xargs
; in that case it works perfectly, with quotes and everything:
echo "-o -name *."{sh,pl,sql} | xargs find . -false
Best Answer
Not with
ls
no. You could, however, use something like these:The reason behind this is that the
shopt
command only affects how globs are expanded by the shell. So, when you runls *a
after running theshopt
command, that gets expanded by your shell toSo, as @Kevin said, the glob is expanded before being passed to
ls
, therefore thenocaseglob
will have no effect when you give a simple string and not a glob.