Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Root825087yI can think of a few situations where grep would make your system unhappy.
In particular, `cat /dev/sda | egrep -a "^(.+)?([^.]+){32,}\2{32,}(.+)?$"` would evoke tears. -
Root825087y@shellbug
It finds a run of 32+ consecutive groupings of one or more (of the same) character that's not a period, immediately followed by at least 32 more consecutive, identical runs of that compound grouping, anywhere in the input line (the data between \n's within /dev/sda' s raw data).
The regex engine needs to find the largest initial match ([^.]+) that also satisfies the second 32+ time run of that same match {32,}, followed by a 32+ time run of that compound match \2{32,}. The initial run uses +, which matches as many chars as possible, and if that fails matching the rest of the regex, it subtracts one from the max length and tries again. It repeats this until it hits 0 characters before deciding the regex doesn't match.
I crafted it to look simple but make grep cry.
(Though with lookahead/lookbehind it could have been substantially worse~)
Related Rants
grep makes my machine's fans go terrifyingly loud
undefined
grep