#!/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