I'm searching for a way to extract the lines between two patterns with awk with the use of variables. Each section ends where the next one starts.
Example file:
[ SECTION_1 ]
info 1
info 2
info 3
[ SECTION_2 ]
info 4
info 5
info 6
[ SOMETHING_SOMETHING_DARK_SIDE ]
...
[ WE_have_COokIES ]
with
awk '/^\[ SECTION_1 \]/{p=1;next} /^\[ [!-~]+ \]/{p=0} p' "${MY_FILE_PATH}"
I get what I want:
info 1
info 2
info 3
But I would like to have something like this:
function get {
awk '/^\[ "$1" \]/{p=1;next} /^\[ [!-~]+ \]/{p=0} p' "${MY_FILE_PATH}"
}
Nothing seems to work :( Any ideas or hints?