grep line after match 1

grep line after match

Include -A flag to add lines after match and -B flag to add lines before
grep match -A 3	#display match line and 3 after lines
grep match -B 2 #display match line and 2 lines before

Here is what the above code is Doing:
1. The first grep command is looking for the word “match” in the file.
2. The second grep command is looking for the word “match” in the file, but it’s also adding the -A flag, which tells grep to add the next three lines after the match.
3. The third grep command is looking for the word “match” in the file, but it’s also adding the -B flag, which tells grep to add the previous two lines before the match.

Similar Posts