GNU find: Pitfalls

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
peter_b
Chatterbox
Posts: 338
Joined: Tue Nov 12, 2013 2:05 am

GNU find: Pitfalls

Post by peter_b »

Pitfall #1: Shell-wildcards in filename search string

I want to search for all files matching "*.wav" or "*.mp3".
The following command seems correct, but it's not:

Code: Select all

$ find . -type f -iname *.wav
In this case, the shell (usually BASH) will expand the wildcard - but only in the current directory you're running the "find" command.

When using any kind of shell-wildcards in the search pattern, they must be quoted:

Code: Select all

$ find . -type f -iname '*.wav'
Post Reply