Hacker News new | ask | show | jobs
by msluyter 4752 days ago
Similarly, I have a little shell function loaded by .zshrc that covers 90% of my use cases:

   findit() {
       find . -name \* -exec grep -iH $1 {} \;
   }
4 comments

Why not just run a recursive grep? That would save having to invoke grep on every single file found.

    findit() {
        grep -iHR $1 .
    }
Alternately, you could use the '+' variant of -exec in order to batch files together to be processed together.
Cool, I wasn't aware of a -R flag in grep for some reason. I need to go back and re-read the man pages...
Right. There's no need to write a whole new tool just to simplify invocation for common cases. For a guy who uses the command line "a LOT" he's not making good use of his shell.
Is this not equivalent and avoids running grep(1) once for each path?

    find -exec grep -iH ${1?} {} +
Though it still runs grep on directories.
Author possibly meant something like this (but yeah, same idea) fffind () { find . -regex ".$1."; }