With a little side of applesauce...

Monday, December 10, 2007

sed - print the match + 4 lines

This took me some time to figure out:

sed -n '/MySearchString/, +4p'" myfile


The grep equivalent, (which was much easier to figure out), is:

grep -h -A 4 "MySearchString" myfile

No comments: