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!
A common mistake involving wildcards and the find command
11–20 of 148 posts
Re: A common mistake involving wildcards and the find command
#12I wonder if this is also a problem with fish. The globing there is different.
find . -name *.py
it will error initially, because there is no "*.py" in the current directory.Globbing is still a thing fish as the shell does, and you still need to protect asterisks that need to reach commands, but you're more likely to notice.
(for bash there is also the "failglob" option that I personally recommend)
Disclaimer: I am a fish developer.
Re: A common mistake involving wildcards and the find command
#13Phew! 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!
Wildcards are still expanded inside double quotes.. Yiu have to use single quotes.
Re: A common mistake involving wildcards and the find command
#14Re: A common mistake involving wildcards and the find command
#15Phew! 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!
Wildcards are still expanded inside double quotes.. Yiu have to use single quotes.
Re: A common mistake involving wildcards and the find command
#16As well as Silver Searcher:
https://github.com/ggreer/the_silver_searcher
while Grep performance is pretty good, its also gotten pretty stale with regard to its defaults and options.
Re: A common mistake involving wildcards and the find command
#17I just finished cleaning away all existing ‘error’ and ‘warning’ level issues in our codebase so that the ‘shellcheck’ CI step can be really strict on code quality.
Re: A common mistake involving wildcards and the find command
#18As another user mentioned, many POSIX and/or GNU utilities havent aged well. I respect trying to stay portable, but peoples needs change over time and these tools simply havent kept up. Like the other user, I use Fd now instead: https://github.com/sharkdp/fd As well as Silver Searcher: https://github.com/ggreer/the_silver_searcher while Grep performance is pretty good, its also gotten pretty stale with regard to its…
Re: A common mistake involving wildcards and the find command
#19Earlier quoted context omitted.
Wildcards are still expanded inside double quotes.. Yiu have to use single quotes.
...or a backslash.
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 :)
Re: A common mistake involving wildcards and the find command
#20Phew! 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!
Wildcards are still expanded inside double quotes.. Yiu have to use single quotes.