grep -A <num of lines above it> string filename | head -1 grep -B <num of lines below it> string filename | tail -1