I'm trying to use sed
to pull out a brace-delimited config block like this from a long file (Junos config):
group foo {
command;
setting {
value;
}
command;
}
The trick is to stop at the }
that's indented the same as the first line.
I learned how to use sed
to match from one pattern to another, and tried this:
$ sed -rn '/^( *)group foo/,/^\1\}/p' config.txt
sed: -e expression #1, char 41: Invalid back reference
Is the problem that /^( *)group foo/
and /^\1\}/
are two separate patterns, and backreferences won't work between them? If so, how can I accomplish this?
//
too, besidess
. Ex.:seq 99|sed -rn '/(.)\1/p'
. – seshoumara Jun 24 '20 at 07:38