how to grep lines before a pattern
cat abc.txt | grep -A 3 "your_pattern" # will grep 3 lines after your pattern..
5
3
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
Thank you!
3
0
4
10
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
Thank you!
10
0
Are there any code examples left?
New code examples in category Shell/Bash