How to select lines between two marker patterns which may occur multiple times with awk/sed
Use awk with a flag to trigger the print when necessary: $ awk ‘/abc/{flag=1;next}/mno/{flag=0}flag’ file def1 ghi1 jkl1 def2 ghi2 jkl2 How does this work? /abc/ matches lines having this text, as well as /mno/ does. /abc/{flag=1;next} sets the flag when the text abc is found. Then, it skips the line. /mno/{flag=0} unsets the flag … Read more