sed [delete everything between two words]

Hi,

I have the following codes below that aims to delete every words between two pattern word. Say I have the files

To delete every word between WISH_LIST=" and " I used the below codes (but its not working):

#!/bin/sh
sed '
/WISH_LIST=\"/ {
N
/\n.*\"/ {
s/WISH_LIST=\".*\n.*\"/WISH_LIST=\"\n\"/
}
}' file.txt

and also I have tried this code:

#!/bin/sh
sed '
/WISH_LIST=\"/ {
N
/WISH_LIST=\".*\"/ {
s/WISH_LIST=\".*\"/WISH_LIST=\"\n\"/
P
D
}
}' file.txt

Any Idea why I can't have the below output from the codes above:

in shell

f=0
while read line 
do
    case $line in
    WISH_LIST* ) f=1; echo $line;;
    '"'* ) f=0;;
    esac
    if [ $f -eq 1 ];then        
        continue
    else
        echo $line
    fi

done < file

Hi.

With sed:

#!/usr/bin/env sh

# @(#) s1       Demonstrate delete lines of range exclusive.
# This solution based on code tutorial at:
# http://sed.sourceforge.net/sedfaq.html
# 2007.12.25

set -o nounset
echo

debug=":"
debug="echo"

## Use local command version for the commands in this demonstration.

echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version bash sed

echo

FILE=${1-data1}
echo " Input file $FILE:"
cat $FILE

echo
echo " Results from sed:"
sed '/WISH_LIST="/,/^"$/{
/WISH_LIST="/b
/^"$/b
d
}' $FILE

exit 0

Producing:

% ./s1

(Versions displayed with local utility "version")
GNU bash 2.05b.0
GNU sed version 4.1.2

 Input file data1:
hello
start
WISH_LIST="
candy
money
t-shirt
"
stop
cool
Christmas

 Results from sed:
hello
start
WISH_LIST="
"
stop
cool
Christmas

A tip of the hat to Eric Pement ... cheers, drl

Or a solution with awk:

awk '/^WISH/{f=1;print} /^"$/{f=0} !f' file.txt

Regards