The grep command has two very useful parameters that let you set how many lines you want to see before or after the line that matches your input. These are aptly named -B (Before) and -A (After). You can use them as follows:
# This example shows 5 lines before and after the lines of the
# output of the 'smartctl' command that contain the string 'status'
smartctl -x /dev/sda | grep -B 5 -A 5 status
Author: Lucas Vieites Fariña ✦ Published: ✦ Updated: ✦
