LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   eliminating text with sed? (https://www.linuxquestions.org/questions/programming-9/eliminating-text-with-sed-755469/)

resolute155 09-15-2009 06:31 PM

eliminating text with sed?
 
Hello,

I have a document and I am trying to remove the square brackets and everything between square brackets. I think I should be able to do this with sed but I can't seem to figure it out...

using Linux bash



the text looks like this:

effective connectivity structural equation modeling [McIntosh et al., 1994] and
dynamic causal modeling [Friston et al., 2003] have




and I would like to remove the [ ] and everything in between to give:

effective connectivity structural equation modeling and dynamic causal modeling have





Any help would be greatly appreciated!

syg00 09-15-2009 06:46 PM

Show us what you've tried and what happened. Sed is designed to do things just like that - metea-characters can need some care though.

d.h 09-16-2009 01:19 AM

Here you go:
Code:

sed 's:\s*\[[^]]*\]\s*: :g'


All times are GMT -5. The time now is 07:11 AM.