Example:This is {the multilinetext file }that wants{ to bechanged} anyway.Should become:This is that wants anyway.I have found some similar threads in the forum, but they don't seem to work with multi-line curly brackets.If possible, I would prefer some one-line method, like solutions based on grep, sed, awk... etc.EDIT: Solutions seem to be OK, but I have noticed that my original files include curly brackets nesting. So I am opening a new question. Thanks you everybody: How can I delete all text between nested curly brackets in a multiline text file?
How can I delete all text between curly brackets in a multiline text file?
text processing;sed;awk;grep
$ sed ':again;$!N;$!b again; s/{[^}]*}//g' fileThis is that wants anyway.Explanation::again;$!N;$!b again;This reads the whole file into the pattern space.:again is a label.  N reads in the next line.  $!b again branches back to the again label on the condition that this is not the last line.s/{[^}]*}//gThis removes all expressions in braces.On Mac OSX, try:sed -e ':again' -e N -e '$!b again' -e 's/{[^}]*}//g' fileNested BracesLet's take this as a test file with lots of nested braces:a{b{c}d}e1{2}3{}5Here is a modification to handle nested braces:$ sed ':again;$!N;$!b again; :b; s/{[^{}]*}//g; t b' file2ae135Explanation::again;$!N;$!b againThis is the same as before: it reads in the whole file.:bThis defines a label b.s/{[^{}]*}//gThis removes text in braces as long as the text contains no inner braces.t bIf the above substitute command resulted in a change, jump back to label b.  In this way, the substitute command is repeated until all brace-groups are removed.