Answers for "grep show lines before and after"

1

lines before and after grep

You can use the -B and -A to print lines before and after the match.

grep -i -B 10 'error' data
Will print the 10 lines before the match, including the matching line itself.
Posted by: Guest on April-21-2021
0

grep find and show lines after

# Use the -A flag.
# Example: 
iptables -L | grep FORWARD -A 10
Posted by: Guest on September-30-2021

Browse Popular Code Answers by Language