How to select several lines before search line in Linux?

Sometimes you need to look for something (i.e. grep) in file, but you want to see several lines BEFORE and AFTER the line you're looking for. So, how can you do this in Linux?
Try:

grep -B 3 -A 3 "Deploying" catalina.out

It looks for text "Deploying" in file catalina.out and returns 3 lines before (-B switch) and after (-A switch) the line with text "Deploying".

Komentarai

Long-temps en Europe, sous des formes variees, les Blancs ont fait la traite des Blancs; peut-on caracteriser
autrement la presse en Angleterre, la conduite
des vendeurs d'ames en Hollande, celle des princes allemands qui
vendoient leurs regimens pour les colonies? http://www.sophiechassat.com

Komentuoti