wild cards on find and ls
bash, linux
Solution
` find -name *{.GIF,.gif}` is wrong.
This command is first expanded by the shell to `find -name *.GIF *.gif`
Then further expanded to :
find -name file_BSD.GIF file_linux.gif
# as you have only these files in directory
Now this `-name file_BSD.GIF file_linux.gif` is passed to `find`. And this is wrong as there is no switch like `file_linux.gif` that is accepted by find.
What you need is this command.
find -name '*.GIF' -or -name '*.gif'
Assuming you want to collect `.gif` files in a case insensitive manner, this find command becomes,
find -iname '*.gif'
Note the single quotes (`'`) here. It means `*.GIF` should be sent to find as is without any shell expansion. And find will use this as pattern. This single quote is necessary unless you escape the shell meta-characters. In that case the command would look like
find -iname \*.gif
Problem
I'm trying to figure out the wild-cards to do file operations. I have these files in a directory for testing purposes: ``` file_BSD.GIF file_linux.gif file_unix ``` See my ls command, ``` $ ls *{.GIF,.gif} file_BSD.GIF file_linux.gif ``` Which is OK. But "find" doesn't seem to work the same way: ``` $ find -name *{.GIF,.gif} find: paths must precede expression: file_linux.gif Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] ``` By the way, I've read that "-iname" should locate both the uppercase and lowercase files, but that doesn't seem to work either: ``` $find -iname *.gif ./file_linux.gif ``` (This should locate the .GIF file as well, right?).