Your Question: How Do You Grep Two Lines in Unix?
Contents How Do You Grep Multiple Lines After a Match? for Bsd or Gnu Grep You Can Use -B Num to Set How Many Lines Before the Match and -a Num for the Number...
Contents
How do you grep multiple lines after a match?
For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for the number of lines after the match. If you want the same number of lines before and after you can use -C num . This will show 3 lines before and 3 lines after.
Must Read
How do you grep between two patterns in Linux?
You can achieve multiline match in grep , but you need to use perl-regexp for grep ( -P – which is not supported on every platform, like OS X), so as workaround we’re replacing new lines with _ character and after grep , we’re changing them back.