Here to plug using `--passthru`/`--passthrough`: it will print all lines, but highlight matches. I often do things like this to watch an output log, but highlight all entries with the string PLUGH in them: tail -F output.log | ag --passthrough '.*PLUGH.*'
Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
41–50 of 101 posts
Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#42This chart doesn't compare speed. Until rg, I didn't grep much because I generally search through a lot of files. rg cuts through them in no time.
For me, raw speed is not as important as a rich feature set to support my code spelunking.
Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#43Earlier quoted context omitted.
The table doesn't yet distinguish between lacking a command line flag due to absence of a feature vs due to the feature being the default. This is similar to the situation with case-sensitive search in GNU grep, which ends up with a blank cell even though it is the default. See: https://github.com/beyondgrep/website/issues/72 It's a fair criticism but I don't think it is designed to be misleading.
Maybe not designed to be misleading, but misleading nonetheless. For `grep`, `grep -i needle` is (approximately) equal to `ack/ag needle`, but looking at the table I wouldn't think grep supports case sensitivity.
Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#44Here to plug using `--passthru`/`--passthrough`: it will print all lines, but highlight matches. I often do things like this to watch an output log, but highlight all entries with the string PLUGH in them: tail -F output.log | ag --passthrough '.*PLUGH.*'
grep '^|.*PLUGH.*'Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#45The chart was created by Andy Lester, the creator of ack, who thinks that more open source projects should point to their "competing" projects because it's not really a competition: http://blog.petdance.com/2018/01/02/the-best-open-source-pro...
Emphasis mine- Excerpt: "Some might say that ag and ripgrep and any of the other tools I list on beyondgrep.com are competing projects, but I think that way of thinking is wrong. It’s only a competition if you see it as a competition. I’m not competing against anyone for anything: Clicks, dollars, popularity, etc. If someone uses ripgrep instead of ack, it doesn’t hurt me. It’s the difference between an abundance vs.…
Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#46A nice feature of ag is the ability to limit the search to a certain file type. E.g. to only search ruby files: ag --ruby foo . To see a list of supported types and the matching file extensions: ag --list-file-types . Just checked and rg does have something similar, but you need to specify the type as an argument to a flag: rg --type ruby foo .
Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#47as a long time user of `find . -name "*.foo" -exec grep -Hin {} \;` moving to ack has been great! I love the syntax and the speed and the fact that it actually respects your ignore files. ripgrep is great too. ag on the other hand is recommended by everyone but doesn't seem to respect ignores or understand modern ignore syntax. give it a pass. https://github.com/ggreer/the_silver_searcher/issues/385 its been over 4 y…
Spawning a separate grep for each file? That's terribly inefficient. At least use xargs which will run one process on as many files as possible. But you know there's a -r for recursive, right? And unless you are using some historic relic of grep that is not GNU or BSD and doesn't understand the --include option you can just do: grep -rin "needle" --include "*.foo" .
find . -iname '.*' -prune -o -iname '*.foo' -exec grep needle {} +
I don't want to have to learn 10 different command syntaxes for walking directory trees, so find works well. The "+" terminator of find's exec is similar to xargs, but preserves the flexibility of find's exec.Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#48Earlier quoted context omitted.
At the least, I recommending moving past `find . --name '*.foo' -exec grep` pattern if you can help it. Modern file searchers, of which `ag` is one among others, accepts `--filenametype` argument and skips the `.git` subdirectory if it exists (by default, can be toggled), so `ag --python needle` will recursively search for needle in the the current working tree in all files whos filenames end in `.py`. Yes, you could…
Or just use "grep". It is what it's there for. Use --include and --exclude-dirs to do what you describe. (The latter is a good idea to set in your GREP_OPTIONS, unless you actually search .git directories.)
(I don't think there's any such plan for the various BSD greps, so if you use those exclusively you're probably fine.)
Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#49Here to plug using `--passthru`/`--passthrough`: it will print all lines, but highlight matches. I often do things like this to watch an output log, but highlight all entries with the string PLUGH in them: tail -F output.log | ag --passthrough '.*PLUGH.*'
Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
#50Ack and ag use Perl/PCRE so they're more useful than grep/rg if you know Perl style regular expressions.