For example, if my file looks like this:
string string1 string2 string4 string800 value2 value3 value5 value10 something18 something20
I want the output to be
string800 value10 something20
The word before the numbers could be anything, but when I said "where a pattern is matched" I meant that I want to keep the highest number where the word before the number is the same, for example, 800 is higher than 10 and 20, but I still want to keep the numbers containing 10 and 20 when the word before is something else than what was before 800, like in my example above.
I need this to work on OSX, so please avoid features that only exist in GNU utilities.