LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-04-2015, 12:23 PM   #1
tlegend33
LQ Newbie
 
Registered: Sep 2013
Posts: 20

Rep: Reputation: Disabled
remove text between patterns recursively


I have a file similar to the below:

create table "aaaaa" ( xxx int
)
;

/*
yadda
yadda
yadda
*/

create table "bbbb" (xxx int
)
;

/*
yadda
yadda
yadda
*/

I wish to remove everything between /* and */. I can run the below, however it stops after removing the first occurrence:

sed '/\/\/*/,/\/\*\//d' tony.log

create table "aaaaa" ( xxx int
)
;

How can I get this to run recursively to generate the below output?

create table "aaaaa" ( xxx int
)
;

create table "bbbb" (xxx int
)
;
 
Old 12-04-2015, 12:49 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,245

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Code:
sed '/\/\*/,/\*\//d' file
 
1 members found this post helpful.
Old 12-04-2015, 12:55 PM   #3
tlegend33
LQ Newbie
 
Registered: Sep 2013
Posts: 20

Original Poster
Rep: Reputation: Disabled
Awesome. Thank you! Guess I got a little slash happy there.
 
  


Reply


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
Bash script to remove string from all text files, recursively iacchi Programming 9 04-27-2012 06:22 AM
scan text for patterns sycamorex Linux - Software 2 04-04-2011 11:03 AM
Remove directories recursively with same name cboyd Linux - Newbie 5 01-14-2007 10:48 PM
Deleting text between two different patterns activeco Linux - General 7 09-13-2005 07:05 PM


All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration