Skip to main content
Post Undeleted by l0b0
added 284 characters in body
Source Link
l0b0
  • 53.6k
  • 48
  • 224
  • 398

The number of patternsMany big files indicate that this needs to matchbe done quickly. That means a while read loop is out of the question. One thing to realize here is small, so youthat each of these exercises can set upbe simplified into matching (at least) one of a listsmall set of regular expressions to capturepatterns, and this can be done really fast using grep or similar tools like rg or ack. For example, for five digit sequences:

grep -e 12345 -e 23456 […] -e 65432 -e 54321

See man grep for more information, and use Greg's Wiki to learn Bash quickly.

The number of patterns to match is small, so you can set up a list of regular expressions to capture this. For example, for five digit sequences:

grep -e 12345 -e 23456 […] -e 65432 -e 54321

Many big files indicate that this needs to be done quickly. That means a while read loop is out of the question. One thing to realize here is that each of these exercises can be simplified into matching (at least) one of a small set of patterns, and this can be done really fast using grep or similar tools like rg or ack. For example, for five digit sequences:

grep -e 12345 -e 23456 […] -e 65432 -e 54321

See man grep for more information, and use Greg's Wiki to learn Bash quickly.

Post Deleted by l0b0
Source Link
l0b0
  • 53.6k
  • 48
  • 224
  • 398

The number of patterns to match is small, so you can set up a list of regular expressions to capture this. For example, for five digit sequences:

grep -e 12345 -e 23456 […] -e 65432 -e 54321