GNU find: Pitfalls
Posted: Thu May 05, 2016 2:54 pm
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:
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:
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
When using any kind of shell-wildcards in the search pattern, they must be quoted:
Code: Select all
$ find . -type f -iname '*.wav'