Skip to content

Commit

Permalink
Set lines to print before and after pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercoll committed Jul 25, 2021
1 parent 38eab9c commit f94af9b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions grep
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ grep -f <pattern-file> <file>
# Find lines NOT containing pattern:
grep -v <pattern> <file>

# Set how many lines to show before (-B) and after (-A) pattern:
grep -B 3 -A 2 <pattern> <file>

# To grep with regular expressions:
grep "^00" <file> # Match lines starting with 00
grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" <file> # Find IP add
Expand Down

0 comments on commit f94af9b

Please sign in to comment.