I have a collection of text files that comprise a mailing list archive. I grep them to find an email that interests me, then open the file in a text editor to find the surrounding paragraph of text. Is there an easy way to do this from the shell instead?
If you want context around the line use the -A, -B, or -C options. For instance:
grep "string" /path_to_directory/ -C50
This will give you 50 lines of context around the line matched. Also, I like to use the --color=always option which gives me the lined matched in color red for easy identification.
Excellent, thanks!