A common mistake involving wildcards and the find command
blog.robertelder.org
A common mistake involving wildcards and the find command
1–10 of 148 posts
Re: A common mistake involving wildcards and the find command
#2Re: A common mistake involving wildcards and the find command
#3Re: A common mistake involving wildcards and the find command
#4Very useful article. And very informative.
Summary:
Instead of -
find . -name *.jpg
Use quotes around pattern i.e. find . -name '*.jpg'
Edit: Oops, the double-quotes should have been single quotes! Thanks, @lucd. Happy case, like I said!Re: A common mistake involving wildcards and the find command
#5Re: A common mistake involving wildcards and the find command
#6I also have the habit of always using -iname instead of -name to make case insensitive searches.
Re: A common mistake involving wildcards and the find command
#7Re: A common mistake involving wildcards and the find command
#8I wonder if this is also a problem with fish. The globing there is different.
Re: A common mistake involving wildcards and the find command
#9Re: A common mistake involving wildcards and the find command
#10http://bash.cumulonim.biz/NullGlob.html
There's a note at the end about how with nullglob set, ls on a glob with no matches does something surprising. This is a great illustration of how an empty list and the absence of a list are different. Sadly it's rather hard to make that distinction in shells!
I do wish that either shells had a more explicit syntax for globbing, or other commands didn't use the same syntax for patterns. Then confusion like this couldn't occur. An example of the former would be if you had to write:
ls $(glob *.txt)
Here, the shell would not treat * specially, but rather you would have to explicitly expand it. This would be a pain, but at least you wouldn't do it by mistake!