Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interestingly enough, awk is many times faster for an inverted grep (grep -v) than grep is. Get a large file and test yourself!

grep -v regex awk '$0 !~ /regex/ {print}'

This is possibly due largely to this not helping in that case:

GNU grep AVOIDS BREAKING THE INPUT INTO LINES.

awk is very fast at breaking the input into lines (that's what it spends most of the day doing!). I don't understand why it's so much slower though. (I had a 100+MB log file that I was searching when I discovered this).



Odds are grep is not super optimized for the -v case...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: