Is it possibile to make grep show a maximum number of words before and after the match? For example, given the row
aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn ooo ppp qqq rrr sss
I d like grep not to return whole line, but only, say, 3 words before and after the match. for example, searching for iii , the result would be
fff ggg hhh iii jjj kkk lll
I ve tried this but no result is returned:
grep -o w{0, 20}MY_SEARCHw{0, 20} *