Quantcast
Channel: Grep for multiple strings, show number of lines after one of the strings (but not the other) - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 4

Answer by heemayl for Grep for multiple strings, show number of lines after one of the strings (but not the other)

$
0
0

You can't do that using one go of grep. You need to use two grep instances :

grep 'string1' file; grep -A 5 'string2' file

If you want to run the second upon success of the first one :

grep 'string1' file && grep -A 5 'string2' file

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>