Hello I need to grep for specific string and I need to print output before/after until a matching word. Here is an example: The string which I search is dmz (I need exact string match because I have similar strings that contain dmz1 which are not in my interest) and I need to print the whole output that start with "edit" until "next"
=============================
edit 1825
set uuid 1e73dff8-2037-51e7-9713-3539a6b60c4c
set srcintf "dmz" <---
set dstintf "tralalala"
set srcaddr tralalala
set dstaddr tralalala
set action accept
set status disable
set schedule "always"
set service "tralalala"
next
===========================
Thanks.
edit
andnext
have to be printed ifdmz
appears between those lines? Also, what do you mean by "exact string"? In my mind,dmz1
contains the exact stringdmz
. In your mind, it doesn't seem to. – berndbausch Feb 25 '21 at 10:44dmz
? What happens if a record contains the worddmz
elsewhere and not with aset srcintf
at the start of the line (likeset service "dmz"
)? – Kusalananda Feb 25 '21 at 10:47