I’ve been more aggressive lately about creating helper scripts and aliases for common tasks, and I liked this find helper enough to want to share it. I find that I often do filename searches like this:
find -iname “*some_word*”
That’s not so bad to type, but why not make it even easier for my, and maybe your common usage? We might prefer to do something like this:
findr some_word
And assume that we’re looking for a case-insensitive, substring match. And since we love regular expressions, we can work with find’s regex options:
–regextype posix-egrep -iregex
Which is just begging for a helper to do the work for us in standard situations.
Before we look at the script and some examples, here are a few more considerations for our findr command:
With the -iregex option, the match is against the whole path, so we’ll wrap the supplied regex search term with dot-stars (.*) to loosen things up. We probably want to limit our match to the last item …
