Interview Prep/Real-World Interview/awk, sed, grep and jq one-liners

Print lines between two markers, e.g. from "BEGIN CONFIG" to "END CONFIG".

IntermediateHands-onawk, sed, grep and jq one-liners
Answer
sed -n '/BEGIN CONFIG/,/END CONFIG/p' file.txt
# exclude the markers themselves
awk '/END CONFIG/{f=0} f; /BEGIN CONFIG/{f=1}' file.txt

Key trick → sed address ranges /a/,/b/ are inclusive. The awk flag pattern, with the order of the three rules, controls whether the markers are printed.

All Real-World Interview questions Roadmap: Interview readiness

More on awk, sed, grep and jq one-liners