|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?|
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”.