LinuxQuestions.org
Review your favorite Linux distribution.
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 06-14-2006, 06:03 PM   #1
rchatman
LQ Newbie
 
Registered: Jun 2006
Posts: 1

Rep: Reputation: 0
Question Sed Issue


I have a line of code in using sed that extracts the frist instance of a word and extracts the entire segment of code associated with that word and writes it to a file. I don't want to extract the lines I want to delet them what am I missing? Here's what I have so far:

sed -e '/./{H;$!d;}' -e "x;/REGEX/!d;" FILENAME > OUT.TMP

Ideally I'd like to redirect the output to OUT.TMP while deleting it from FILNAME all together.

The output in OUT.TMP would look like this

this is REGEX and stuff
I'm apart of the REGEX paragraph
this is the last line that will be read because the next line is blank
 
Old 06-15-2006, 02:52 PM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
To extract that part, I guess it's best to use
Code:
sed -ne '/REGEXP/,/^$/p' > OUT.TMP
To delete it from the file, I think you'll have to invoke sed once again:
Code:
sed -ie '/REGEXP/,/^$/d'
 
  


Reply

Tags
homework, removing, 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
Command interpretation issue in Sed script file angel115 Programming 9 04-21-2006 08:26 PM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 01:34 AM
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-04-2005 12:00 AM
webmin issue, poss security issue bejiita Slackware 3 11-03-2004 07:07 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 07:12 AM


All times are GMT -5. The time now is 07:03 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration