Sometimes we may want to grep for some words, and because the line is too long, sometimes even the whole file on one single line if it is a generated file, we may only want to see some characters before and after the match.
In that case, we can use something like:
grep -o -E '.{30}theword.{30}' somefile.html
or
curl https://somewebsite.com | grep -o -E '.{30}theword.{30}'
The -E
says to treat it like it is egrep, and -o
means only output the matched characters but not the whole line.
Top comments (0)