I have a document containing some text inside square brackets, e.g.:
The fish [ate] the bird.
[This is some] text.
Here is a number [1001] and another [1201].
I need to delete all of the information contained inside the square brack and the brakets, e.g.:
The fish the bird.
text.
Here is a number and another .
- I tried
sed -r 's/\[[+]\]//g' file.txt
, but this did not work.
How can I delete anything in the pattern [<anything>]
?
try this sed line:
example:
explanation:
the regex is actually straightforward:
so it is
match string, starting with
[
then all chars but]
and ending with]
sed 's/([^])*)/replacement text/g' in case of Parenthesis ()