How can I efficiently remove enclosing brackets from a file with bash scripting (first occurrence of [
and last occurrence of ]
in file)?
All brackets that are nested within the outer brackets and may extend over several lines should be retained.
Leading or trailing whitespaces may be present.
content of file1
[
Lorem ipsum
[dolor] sit [amet
conse] sadip elitr
]
cat file1 | magicCommand
desired output
Lorem ipsum
[dolor] sit [amet
conse] sadip elitr
content of file2
[Lorem ipsum [dolor] sit [amet conse] sadip elitr]
cat file2 | magicCommand
desired output
Lorem ipsum [dolor] sit [amet conse] sadip elitr