I have a file from which I want to remove a block of code present inside { }. I tried using the command sed '/method2/,/}/d' filename.txt but the problem I have is I have other } inside the block I want to remove and my command removes only till the first occurrence of closing curly braces.
The contents of my file will look like this.
line of code1
line of code2
method1 {
fjdsjfahldkj
dsnfbdjvffd {}
}
method2 {
fshfjkadhfjd {}
}
method3 {
fkjvfdvfd{}
snlvfk{}
}
I want "
method2 {
fshfjkadhfjd { }
}
" to be removed from the file.
Note: The contents of method2 can change as in there may be other lines with more {} braces as well. Could someone help me with a command to remove this block of code. Your help is much appreciated.