add few lines to a file in unix

Hi,

I have an xml file
<Disp
x=y a=b
Disp/>
<Disp
q=1 w=2
Disp/>
.....

I want to add a new set in between like this for a set of 100 files.
<Disp
x=y a=b
Disp/>
<Disp
k=1 z=2
Disp/>
<Disp
q=1 w=2
Disp/>
.....

is it possible to achieve through sed or i should go with some thing else?

you don't say what is the condition to know in which line insert.
This is a example for insert in a specific line (line 2) of a file using sed:

$more file_in
line1
line2
line3
$cat file_in | sed '2 i <Disp\nk=1 z=2\n Disp/>' >file_out
$more file_out
line1
<Disp
k=1 z=2
 Disp/>
line2
line3

Hi,

Please can you specify the condition were the line needs to get inserted or is it that it can be inserted in any place between the first and the last.

Cheers,
Shazin

Hi,

<Disp apple
x=y a=b
Disp/>
<Disp grapes
k=1 z=2
Disp/>
<Disp orange
q=1 w=2
Disp/>

I have a sequence of such <Disp> tags in my file, I want to add the Disp tag with name grapes above the disp tag of orange. This is the case for all 100 files.
The orange tag may present anywhere in the file.

I am seeing for a script which inserts the 3 lines of the grapes tag above the orange tag.

in reality the solutio i propose you isn't and insert because use 's' that means sustitution:

$more file1
<Disp apple
x=y a=b
Disp/>
<Disp orange
q=1 w=2
Disp/>
$cat file1 | sed "s/<Disp orange/<Disp grapes\nk=1 z=2\nDisp\/>\n<Disp orange/"
<Disp apple
x=y a=b
Disp/>
<Disp grapes
k=1 z=2
Disp/>
<Disp orange
q=1 w=2
Disp/>

Output i got for
$cat file1 | sed "s/<Disp orange/<Disp grapes\nk=1 z=2\nDisp\/>\n<Disp orange/"
Output:
<Disp grapesnk=1 z=2nDisp/>n<Disp orange

It dosen't recognize /n for new line.

in GNU/Linux work fine, now i probe in HP-UX and i got the same result, command print n...
is like in this part of the argument the comand don't interpret \n....

---------- Post updated at 11:46 AM ---------- Previous update was at 11:30 AM ----------

i try to escape de \n in all forms that i know but with the same result...
i find a solution in Internet, i don't like so much but it work fine un UNIX plataform.You need to write the script exactly like i put:

$more sed1.sh
cat file11 | sed 's/<Disp orange/<Disp grapes\
k=1 z=2\
Disp\/>\
<Disp orange/'

in this URL you have and explication:
Sed - An Introduction and Tutorial

I supose the version of sed in linux support to put \n in left side of a substitute command...

Hi Thanks a lot ... It worked...