Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting a range of lines

Status
Not open for further replies.

rfrenke

Programmer
Joined
Jun 21, 2003
Messages
9
Location
US
I'm trying to wriet an installation script. In this script it appends the end of a text file with 36 lines of user defined parameters. Before it appends the file I need it to look for the same block of text and delete it, because the program will use the parameters defined first in the file. I would just delete the parameter file first and rewrite it, but there are other parameters defined in it that can't be deleted.

Here is the basic layout of the section that appends the parameter file.

Code:
echo "#~~~ Begin Program Parameters" >> parameters ;
echo "VARIABLE1 = value1"            >> parameters ;
echo "VARIABLE2 = value2"            >> parameters ;
echo "Enter the value for VARIABLE3";
read value3 ;
echo "VARIABLE3 = $value3"           >> parameters ; 
echo "#~~ End Program Parameters"    >> parameters ;

I'm pretty new with shell scripting, and am lost at this point.
 
Something like this should do it:

Code:
sed '
        /^#~~~ Begin/,/^#~~ End/d
        $a#~~~ Begin new stuff VAR=NEWVALUE #~~ End new stuff
' parameters


Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top