LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Sed Issue (http://www.linuxquestions.org/questions/programming-9/sed-issue-454816/)

rchatman 06-14-2006 05:03 PM

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

spirit receiver 06-15-2006 01:52 PM

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'


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