Given a file Sample called movieslist.
Troy
Gladiator
Robin Hood
King Arthur
BraveHeart
The Last Samurai
Normal grep returns
grep "Gladiator" movieslist
Gladiator
Now,using grep to print the below or above lines of the file.
To print the below line
grep -A 1 Gladiator movieslist
Gladiator
Robin Hood
To print the above line
grep -B 1 Gladiator movieslist
Troy
Gladiator
To print both
grep -C 1 Gladiator movieslist
Troy
Gladiator
Robin Hood