News for hackers. Stuff that matters.
Re:Ask HN: Can I see your scripts? by ansible on Monday August 15, 2022 @11:02AM (#32470562)
I use find and grep a lot in code repos, so I came up with this bash function:

    alias filter_repos_z="grep -ZzEv '/tags|/\.hg/|/\.svn/|/\.git/|/\.repo/|\.o$|\.o\.cmd$|\.depend|\.map$|\.dep$|\.js$|\.html$'"
    function findxgrep()
    {
    find . -type f -print0 | filter_repos_z | xargs -0 grep --color=auto "${@}" | grep -v "^Binary file" | sed 's/^\.\///' | less -F
    }
The "${@}" is the critical bit that allows me to pass arguments like -i to grep. The grep, find and xargs commands all support using a NULL as a file separator instead of whitespace.
Re:Ask HN: Can I see your scripts? by dstarh on Monday August 15, 2022 @11:38AM (#32471048)
Ever used ack?
Re:Ask HN: Can I see your scripts? by ansible on Monday August 15, 2022 @12:21PM (#32471664)
No, but thanks for pointing out its existence. Homepage:

https://beyondgrep.com/

Re:Ask HN: Can I see your scripts? by Beltalowda on Saturday August 20, 2022 @12:57AM (#32529203)
the_silver_searcher and ripgrep are similar (and inspired by Ack). I switched from ack to the_silver_searcher years ago as it's quite a bit faster (or was at the time anyway, not sure how fast Ack is now), and then to ripgrep because it has the -g option (only search files that match a pattern) that's handy sometimes.