I have a file with lines like
text text text 3424 text text 3423 50 US text 342 text
What I want to match is 50 US (yes, dollars) and ultimately extract that number.
Everything else changes in different lines, there may be more text or less surrounding, but in each line there is only one “US” anchor that I can match.
So what I want to do is to find a way to match US and get the preceding 3 or 4 characters.
Any ideas? Preferably with sed/awk, but any solution will do.
Perl regexes (or anything that understands non-greedy
.*?expressions) are easier than sed for this:That will handle things like “11.23” as well.