Searching a file for a string is fairly straight forward, usually involving the cat *** | grep *** command. Whilst this is appropriate in most instances, I am trying to search a file for a string for which a substring will be randomised.

To elaborate, the command I am looking for would identify the string by the 2 substrings Threat: and detected, however the single word which would exist between those 2 words, would be randomised, e.g. Threat: 'unimportant_garbage' detected.


Grep can do this

grep 'Threat:.*detected'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.