LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-15-2009, 06:31 PM   #1
resolute155
LQ Newbie
 
Registered: Dec 2006
Posts: 9

Rep: Reputation: 0
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!
 
Old 09-15-2009, 06:46 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,205

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
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.
 
Old 09-16-2009, 01:19 AM   #3
d.h
LQ Newbie
 
Registered: Sep 2009
Posts: 3

Rep: Reputation: 0
Here you go:
Code:
sed 's:\s*\[[^]]*\]\s*: :g'
 
  


Reply

Tags
sed


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sed append text to end of line if line contains specific text? How can this be done? helptonewbie Linux - Newbie 4 10-23-2013 01:48 PM
using sed to replace text on one line in a text file vo1pwf Linux - Newbie 5 06-24-2009 07:54 AM
sed: delete text till <pattern2> depending on length of text oyarsamoh Programming 2 05-05-2007 01:40 AM
sed - appending text 7stud Linux - Newbie 2 03-01-2007 02:10 PM
SED - display text on specific line of text file 3saul Linux - Software 3 12-29-2005 04:32 PM


All times are GMT -5. The time now is 05:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration