4 ms·
Lots of performance fixes, which is great because grep is already very performant! If you're ever bored, try writing your own grep or grep similar tool in your
by freedomben 6y ago
Lots of performance fixes, which is great because grep is already very performant! If you're ever bored, try writing your own grep or grep similar tool in your favorite language (I tried it in Go[1] to both learn Go and make a tool that I wanted that didn't exist (at the time)). The naive solution won't take long, but from there you can parallelize and optimize. It's a fun and highly practical exercise and you'll gain an appreciation for the clever algorithms that grep uses.
More a comment for the newer members of our community: If you don't know grep, you should definitely learn it. It's both the weirdest tool (when you are new to *nix) and the most useful. I procrastinated a couple of years learning grep and now 10 years later I use it dozens of times a day. Grep is one of the most important productivity tools in my development environment and a critical component for understanding and writing shell scripts.
[1]: https://github.com/FreedomBen/findref https://github.com/FreedomBen/findref
- yissp 6y agoSee "why GNU grep is fast" https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html https://lists.freebsd.org/pipermail/freebsd-current/2010-Aug...
- freedomben 6y agoAwesome, thanks for this link. I remember finding this years ago when I was first rolling my own but had forgotten. This is a great resource.
- globuous 6y agoThis one's also a classic! https://ridiculousfish.com/blog/posts/old-age-and-treachery.html https://ridiculousfish.com/blog/posts/old-age-and-treachery.... ;)
- innagadadavida 6y agoOne of the coolest grep features is exposed in the -f argument (aka fgrep) - it implements searching for any token present in the file argument. This basically implements the Aho-Corasick algorithm and is pretty amazing.