I have a problem similar to Print text before and after match, from a specific beginning and to an ending string but with a twist.
My file is a large CSV which was manually constructed. It contains the string "WAP" many times. My job is to detect all instances of the string WAP and print the character that comes two characters before each match, so long as that character is a number.
I've never needed to do string searching like this, so any guidance you can offer will be majorly helpful to my task. Thanks all.
~ daniel ~
Sample from spreadsheet:
,x,x,x,x,x,xx,Yes,"1 WAP, other stuff, other stuff",no,x
Intended output from that line:
1
this was how far I got because i've never had to use awk before:
awk '/WAP/{print}' ~/spreadsheets/waps.csv
which seems to want to print each matching line. What I think I need to do is to keep a loop running that accumulates characters up until the WAP is matched, then grabs the character two earlier. But last time I did that was in university in 1999.
It contains the string "WAP" many times
- can it occur multiple times in one line? If so include that in your sample input/output.