LinuxQuestions.org
Visit Jeremy's Blog.
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 10-20-2011, 10:35 PM   #1
lityit
LQ Newbie
 
Registered: Oct 2011
Posts: 8

Rep: Reputation: Disabled
how do you replace text between two words in a whole file not just 1 line w/ sed/awk


For example, if I wanted to replace everything between WORD ONE and WORD TWO bellow, how can I do it?
Quote:
A paragraph (from the WORD ONE blah blah blah blah blah blahahaaahhh bblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah WORD TWO blah blah blah blah blah blah blah blah blah blah blah blah
 
Old 10-21-2011, 12:15 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Hi, welcome to LQ!

Are these on one line, or several? From your sample it looks as if they
are one line, wrapped around.


Cheers,
Tink
 
Old 10-21-2011, 12:58 AM   #3
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,562

Rep: Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939
And what have you tried? I see you mention sed and awk ... have you tried either? are you stuck? if so, where?
 
Old 10-21-2011, 05:44 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Please use [code][/code] tags around your code, to preserve formatting and to improve readability.

Do not use quote tags for this purpose.
 
Old 11-03-2011, 04:47 PM   #5
lityit
LQ Newbie
 
Registered: Oct 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Code:
 
blah blah WORD ONE blah blah blah blah blah blahahaaahhh bblah blah blah 

blah blah blah blah blah blah blah blah blah blah blah blah blah blah b
lah blah blah blah blah 
blah 
blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah WORD TWO blah 
blah blah blah blah blah blah blah blah blah blah blah
 
Old 11-04-2011, 12:04 AM   #6
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,562

Rep: Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939
Is there a question here? Just looks like more data to me.
 
  


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
using sed to replace text on one line in a text file vo1pwf Linux - Newbie 5 06-24-2009 07:54 AM
replace a pattern with a line using sed/awk lokeshn05 Linux - Newbie 3 05-06-2009 03:01 PM
bash/sed/awk fill each line in text file with space to fixed length khairil Programming 11 01-09-2008 05:28 AM
Need to strip words from front of line. sed/awk/grep? joadoor Linux - Software 6 08-28-2006 04:39 AM
SED - replace text in file on specific line 3saul Linux - Software 1 03-04-2006 07:01 PM


All times are GMT -5. The time now is 10:19 PM.

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