Custom Search

Monday, March 14, 2016

grep a file and print some lines before and after the matching line

1)
Print matching line with 2 lines after the matching line
$grep -r -A 2 install neutron.conf

2)
Print matching line with 2 linee before the matching line
$grep -r -B 2 install neutron.conf

3)
Print matching line with 2 lines before and after the matching line
$grep -r -C 2 install neutron.conf


No comments:

Post a Comment