back

by thunderbong·6y ago·view on hn ↗
Phew! I'm glad I've been hitting the "Happy Case" scenario all these years!

Very 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!
1 comments
Wildcards are still expanded inside double quotes.. Yiu have to use single quotes.
That's not true. Variable expansion happens in double quotes, but globs stay untouched.
...or a backslash.
I use the backslash. I also specify -type f explicitly when I’m looking for files.

find . -type f -name \*.txt

Now the next article will talk about problems when there’s a space in the file names and you just piped the output into xargs :)

Yes but double quotes will work fine in this case -- globs won't be expanded...