Welcome to The ABC’s of p4 grep!
Here we will explore the different flags for the p4 grep command.
Much like the regular grep
, use the -B
flag to show the lines before the matching search term is found.
Suppose you have a file named test.txt
with the following content:
sad
happy
awake
coffee
work
school
You would search for the word “happy” like this:
$ grep -e happy test.txt
//depot/test.txt#6:happy
To see the first line before happy, execute the following:
$ grep -B 1 -e happy test.txt
//depot/test.txt#6-sad
//depot/test.txt#6:happy