5
armaged
7y

grep makes my machine's fans go terrifyingly loud

Comments
  • 1
    Well then it must be an older machine
  • 4
    I 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.
  • 0
    @Root what's that regex for?
  • 2
    @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~)
Add Comment