Grep multiple lines:
$ apt-get install pcregrep
$ pcregrep -M 'first_line\nsecond_line' file.txt
Additionally you can print some lines before and after matched string. To print one line Before and two lines After matched string, use switches:
$ grep -B 1 -A 2 'regex' file.txt
No comments:
Post a Comment