Script to add a single line to middle of text file.

I've got a configuration file that is filled with xml text statements for example:

<...../>
<...../>
<...../>
<data id="java-options" value="-server -Djava.security.policy..../>
<...../>
<...../>
<...../>

I want to write a korn shell script that will go to this specific line and add a certain parameter as follows:

<data id="java-options" value="-server -My_Parameter -Djava.security.policy..../>

I'm thinking that I can do this with head and tail but I'm not sure how to do it. Any help help would be appreciated.

head and tail cannot add any information on their own. For easy string replacements, you probably want sed.

sed -e '/<data /s/-server/& -My_Parameter/' file >file.new

This will search for "<data" and perform a substitution ("s") of "-server" with "-server -MyParameter" (the & is magical and means "whatever we are substituting") on that line. Other lines are printed unchanged.

This works perfectly, thank you!