Using this:
grep -A1 -B1 \"test_pattern\" file
will produce one line before and after the matched pattern in the file. Is there a way to di
You could use
awk '/test_pattern/ { match($0, /test_pattern/); print substr($0, RSTART - 10, RLENGTH + 20); }' file