Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 06-14-2006, 05:03 PM   #1
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, 01:52 PM   #2
spirit receiver
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
sed -ne '/REGEXP/,/^$/p' > OUT.TMP
To delete it from the file, I think you'll have to invoke sed once again:
sed -ie '/REGEXP/,/^$/d'


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 07:26 PM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 12:34 AM
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-03-2005 11:00 PM
webmin issue, poss security issue bejiita Slackware 3 11-03-2004 06:07 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:06 PM.

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