7 ms·
I combine "find ./" and grep instead of learning how to use find. (I'm a terrible person.)
by gregwtmtno 11y ago
I combine "find ./" and grep instead of learning how to use find. (I'm a terrible person.)
- bane 11y agoYou mean that's not how you're supposed to use it? It's such an utterly terrible tool and needs replacing bad.
- untothebreach 11y agoI have found it helpful to learn small parts of the `find` api a bit at a time. For example, instead of `find ./ -print | grep "name_of_file"`, I use `find ./ -name "name_of_file"` or `find ./ -name '* name_of_file *"` (without the spaces -- I can't seem to surround text with asterisks without it triggering HNs formatting (yes I tried escaping them)) if you want to fuzzily search for a filename. You can replace `-name` with `-iname` if you want your search to be case-insensitive.
- maw 11y agoFor all I know you may indeed be a terrible person ;), but this isn't why. The composability of Unix' commands is probably its greatest strength.
- marcosdumay 11y agofind . | grep 'abc' === find . -name 'abc' find . | grep -i 'abc' === find . -iname 'abc' Here, saved you a pipe :) (Oh, and with -exec and -delete, not needing that pipe is incredibly useful. Find is an incredibly powerful command.)
- Sodel 11y agoSorry if this is pedantic, but actually: find . | grep 'abc' === find . -name '*abc*' find . | grep -i 'abc' === find . -iname '*abc*' The -name and -iname options do a verbatim file name check if you don't include those wild-card asterisks. I've been inconvenienced by having to go back and add them often enough that this is burned into my brain. :-)
- paulmd 11y ago-name and -iname are the commands to know. But yeah, I think that's the default novice way of using find. I cannot agree with you and the article hard enough - I have an intense, irrational aversion to using 'find' that's absolutely incomparable to my feelings on any other Unix tool. I really can't think of any other utility which needs so many inane arguments to achieve a basic level of functionality. I even hate cracking open the manpages on it - I'll try to bring myself to do it, and then I decide "you know what, fuck it, I'll grep for it". This is where I throw in a quick plug for bropages. Best tool ever, cannot recommend strongly enough. It's the second thing I install on a new system, right after etc-keeper.