Extracting Text Between Two Unique Lines

Hi all! Im trying to extract a portion of text from a file and put it into a new file. I need all the lines between <Placement> and </Placement> including the Placemark lines themselves. Is there a way to extract all instances of these and not just the first one found? I've tried using sed and awk but I cant seem to get the format right. Say the original file is called file.kml and the new one newfile.kml. If it helps its on a Solaris box.

Original File

...
<Placemark>
...
...
...
</Placemark>
...
...
<Placemark>
...
...
...
</Placemark>
...

New File

<Placemark>
...
...
...
</Placemark>
<Placemark>
...
...
...
</Placemark>

Thanks!

Hi,

Try this.

 awk '/<Placemark>/,/<\/Placemark>/ {print}' file

Regards,

Ranjith

sed  -n '/<Placemark>/,/<\/Placemark>/p' file

---------- Post updated at 12:18 AM ---------- Previous update was at 12:18 AM ----------

sed -n '
/^<Place/!b
:loop
$!{
N
/<\/Place/!b loop
}
p' place

:slight_smile:

awk '/<Placemark>/,/<\/Placemark>/' file

So file is the file its reading or the file its writing the output too?

####
I figured it out. :wink: