I have this file, that contains - among other quite random things - blocks like this:
# MODE:
bindsym $mod+z mode "$system_mode"
mode "$system_mode" {
bindsym Return mode "default"
bindsym Escape mode "default"
}
foo
# MODE:
bindsym $mod+z mode "$other_mode"
mode "$other_mode" {
bindsym blah blah mode "default"
bindsym foo bar "default"
}
bar
And I need to extract those to another file. I tried every option in the answers to this post but I got as far as extracting one block:
sed -e '1,/# MODE:/d' -e '/}/,$d' FILE
returns
bindsym $mod+z mode "$other_mode"
mode "$other_mode" {
bindsym blah blah mode "default"
bindsym foo bar "default"
And it is exactly what I need, but How can I get it to return all the blocks?
For some reason in the real file, the block returned is the first ; But with the above example, the block returned is the last one.
PS - I would prefer a "standard CLI tools" solution, but Perl or Python are acceptable, since they tend to be available anywhere nowadays.