Get 20 lines above string found, and 35 below string

view story

http://www.unix.com – i want to search a log for a string. when that string is found, i want to grab the a set number of lines that came before the string, and a set number of lines that come after the string. so if i search for the word "Error" in the /var/log/messages file, how can I output the 20 lines that came directly before it and the 35 lines that come after it..and also output the line that contained the specified string of "Error"? im thinking a mixture of sed and awk can work here? OS: Linux / SunOS shell: bash (HowTos)