Pregunta

I have a text file in HPUX and I have to insert some xml at a specific location in the file, for example, I have to insert some text after this

<Table name="DATA" keys="CONTEXT_ID,USERNAME">  

...my text here

in linux i have done this using 'sed' but the same command gives error in HPUX, unable to parse...

please help

In Linux, I have used sed like this

sed '\|<table name="MANAGED_USER" keys="CONTEXT_ID,USERNAME">| a \ my text here' file.xml >> file1.xml
¿Fue útil?

Solución

I was looking for something similar in my shell script.

This article solved my problem: http://www.theunixschool.com/2012/06/insert-line-before-or-after-pattern.html

The one I used:

    awk '/pattern/{print "your text here"}1' $FILE > /tmp/patawk
    cp /tmp/patawk $FILE 
    rm /tmp/patawk
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top