News for hackers. Stuff that matters.
Re:A common mistake involving wildcards and the find command... by xen0 on Friday December 10, 2021 @04:23AM (#29508025)
I've never claimed to be good at command-line-fu, but damn me if I can ever get a find command right first time.

Honestly, I just run 'find . | grep' to achieve what I want these days.

Re:A common mistake involving wildcards and the find command... by petepete on Friday December 10, 2021 @08:04AM (#29509361)
Give fd a try. It work how you'd expect find would.

https://github.com/sharkdp/fd

Re:A common mistake involving wildcards and the find command... by asicsp on Friday December 10, 2021 @04:32AM (#29508085)
I have this shortcut for such cases. An important difference from your command is that I'm still using glob, not regex. You can use `-regex` if needed.

    fs() { find -iname '*'"$1"'*' ; }
Re:A common mistake involving wildcards and the find command... by enriquto on Friday December 10, 2021 @04:53AM (#29508210)
find|grep is perfectly alright. There's no shame in using it.
Re:A common mistake involving wildcards and the find command... by avaika on Friday December 10, 2021 @05:46AM (#29508458)
As long as you don't have files with newline character (which is totally valid, but fortunately not widely used).

However even without newline it will be fun to process all the special symbols in file names if you decide to handle somehow the matched files.

PS Unless I missed /s in your message, which I'm not always good at :)

Re:A common mistake involving wildcards and the find command... by enriquto on Friday December 10, 2021 @06:08AM (#29508569)
I was being serious. Most often you get to choose, or at least to know, the names of your files. In those cases find|grep is very useful. You do not need your shell commands to always work in the fully general case.