I'm using egrep with the -o option in order to just get the matching part of the line, e.g.
cat /usr/share/dict/words | egrep -o '(aa|ii)'
Now I'd like to see some context of the match, i.e. a few characters on the left and on the right. One way to achieve this is by
cat /usr/share/dict/words | egrep -o '.{3}(aa|ii).{2}'
Is there a better (more efficient and elegant) way? (I've gone through the egrep commandline options but didn't find one for this purpose.)
grep -A/B/Cand was asking for color, file names and line numbers. This one is simpler as it only asks for context around a (or several) match within a line.