1

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
Techie
  • 25
  • 5
  • 1
    What's your sed expression in Linux? – John Zwinck Jun 22 '13 at 10:03
  • @Techie: Is something wrong with the copy/pasted Linux sed example? It's certainly not correct as-is. Your problem may stem from the fact that GNU sed is more sophisticated and allows `\n` in places other sed do not. Perhaps you have gsed available on HP-UX? – sorpigal Jun 23 '13 at 18:11
  • Ok, lets make it simple, Can anyone tell me the command to find a phrase in text file and insert some text just after it in HP-UX? – Techie Jun 25 '13 at 08:28

1 Answers1

0

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
Sid
  • 36
  • 4