Skip grep, use awk
blog.jpalardy.com
Skip grep, use awk
1–10 of 136 posts
Re: Skip grep, use awk
#2Re: Skip grep, use awk
#3Isn't rg the hot one for grep replacement these days?
Re: Skip grep, use awk
#4Isn't rg the hot one for grep replacement these days?
Re: Skip grep, use awk
#5Isn't rg the hot one for grep replacement these days?
Re: Skip grep, use awk
#6For example: GNU grep uses a heavily optimized implementation of the Boyer-Moore string search algorithm [1] which (it is claimed) requires just 3 (x86) cycles per byte of input. Boyer-Moore only searches for literal strings, but grep will extract the longest literal from the search regex (e.g. the string "foo" from the regex /foo(bar|baz)+/) and use Boyer-Moore to find candidate matches that are then verified using the regex engine.
So if you have a large corpus of text to search, grep is your friend. It can easily saturate your I/O bandwidth and perform an order of magnitude faster than typical "big data" platforms. [2]
[1] https://lists.freebsd.org/pipermail/freebsd-current/2010-Aug...
[2] https://aadrake.com/command-line-tools-can-be-235x-faster-th...
Re: Skip grep, use awk
#7Re: Skip grep, use awk
#8While awk is indeed under-appreciated, there are many instances where using grep to pre-filter your input is helpful because the grep family (GNU grep, agrep, etc.) can match strings much much faster than awk's regex engine. For example: GNU grep uses a heavily optimized implementation of the Boyer-Moore string search algorithm [1] which (it is claimed) requires just 3 (x86) cycles per byte of input. Boyer-Moore only…
Re: Skip grep, use awk
#9While awk is indeed under-appreciated, there are many instances where using grep to pre-filter your input is helpful because the grep family (GNU grep, agrep, etc.) can match strings much much faster than awk's regex engine. For example: GNU grep uses a heavily optimized implementation of the Boyer-Moore string search algorithm [1] which (it is claimed) requires just 3 (x86) cycles per byte of input. Boyer-Moore only…
I have found ack and ag to be much faster than grep (I should actually time this).
Re: Skip grep, use awk
#10To address one of the benefits, `egrep ^[^#]` is shorter than `awk '/^[^#]/'`.