If two patterns are found then convert in into single line from start to end pattern.
Example-
cat test.txt
qwe rty
uio {asd
fgh jkl
zxc} vbn
mqw rty
Now desired o/p should be
qwe rty
uio {asd fgh jkl zxc}
vbn
mqw rty
Here First pattern is "{" and second pattern is "}"
Thanks.
Solution in TXR.
datais:data.txris:@pre@{postmeans we match a line which contains a{character. Everything before the{character goes into theprevariable; everything after goes topost.Then
freeform " "means that for the purposes of subsequent matching, the input lines are considered to be one single line, in which they are joined by spaces. Inside this one giant line we match@rest}: a prefix portion which goes into the variablerestup to a closing brace, and we match the brace also and a following space. If all this material matches, we output it as one line.If there is no match such as the above, the second case matches a line, capturing it into
nomatchand that is put out as-is.The surrounding
repeatthen marches down past the matched lines to try matching again.