Shell Script to insert text after Tag


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script to insert text after Tag
# 1  
Old 09-26-2013
Shell Script to insert text after Tag

Hello,

I'm doing an Shell Script to insert a text on XML file, i tried sed, awk, perl... i'm doing something wrong, please help me Smilie

well, the script is a bit large, i get some infos on script before 'run' this part to insert the text on XML...

Code:
domobile() {
    let i++
    echo
    echo "${i}. Auto mobile stream install"
	sed 's/.*<StartupStreams>.*/&\n<StartupStream>
	<Application>$login/_definst_</Application>
	<MediaCasterType>shoutcast</MediaCasterType>
	<StreamName>$login.stream</StreamName></StartupStream>/' ${INSTALLDIR}/conf/StartupStreams.xml

}


basically, after the tag <StartupStream> i need to add these infos;

Code:
<StartupStream>
	<Application>$login/_definst_</Application>
	<MediaCasterType>shoutcast</MediaCasterType>
	<StreamName>$login.stream</StreamName>
        </StartupStream>

can you guys help me?
Moderator's Comments:
Mod Comment Please use CODE tags for multi-line code, input, and output samples; not ICODE tags.

Last edited by Don Cragun; 09-26-2013 at 11:57 PM.. Reason: Fix tags.
# 2  
Old 09-26-2013
Please edit your post and retag all CODE's to ONE CODE segment...
Dont mark every each single line, mark ALL LINES (in a row) as CODE.

Describe in between...

Then mark again as CODE..

EDIT1: sed line seems incomplete...
I know sed lines like:
Code:
sed s,"search","replace",g FILE
sed s/"search"/"replace"/g FILE
sed s\\"search"\\"replace"\\g FILE

Which one works best depends on the strings to replace...
hth
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Multiline html tag parse shell script

Hello, I want to parse the contents of a multiline html tag ex: <html> <body> <p>some other text</p> <div> <p class="margin-bottom-0"> text1 <br> text2 <br> <br> text3 </p> </div> </body> (15 Replies)
Discussion started by: SorcRR
15 Replies

2. Shell Programming and Scripting

How to insert a CSV within xml element tag using Python?

Hi Team, I have a CSV file which I have to read through and needs to insert the content within an XML file using Python ONLY ( as most of the code base we have in python only). I managed to find the first part, missing how to insert to XML under "specific" tags. cat input.csv... (0 Replies)
Discussion started by: panyam
0 Replies

3. Shell Programming and Scripting

Read xml tags and then remove the tag using shell script

<Start> <Header> This is header section </Header> <Body> <Body_start> This is body section <a> <b> <c> <st>111</st> </c> <d> <st>blank</st> </d> </b> </a> </Body_start> <Body_section> This is body section (3 Replies)
Discussion started by: RJG
3 Replies

4. Shell Programming and Scripting

Print a closing XML tag shell script

I have a shell script that does everything I need it to do. But, when I was testing it I realized it doesn't print the closing XML tag.... Does anyone know how to incorporate printing the XML tag with my script? I am using AWK any help would be appreciated. (4 Replies)
Discussion started by: risarose87
4 Replies

5. UNIX for Dummies Questions & Answers

Insert text into a file using shell script

Hi, I need to insert "Hello World" text into a file called hai.txt using shell scripting. Kindly help me. For eg: If I open the file hai.txt by giving linux command cat hai.txt, the content of the file should have the text Hello World in it. Thanks (5 Replies)
Discussion started by: karthick nath
5 Replies

6. Shell Programming and Scripting

awk command to insert a tag in XML

Hi All, I need a help on inserting a XML tag. Actual input <var> <nam>abcd</nam> <a1>.</a1> </var> if tag <a1>.</a1> is getting missed in XML like below <var> <nam>abcd</nam> </var> i need to insert wherever it is missed after <nam> tag and before </var> tag. Could anyone... (3 Replies)
Discussion started by: mohanalakshmi
3 Replies

7. Shell Programming and Scripting

Modify XML tag using shell script

Hi All Need some help with a unix shell script. I have a XML file as shown below: <Root> <Service> <endPoint type="SOAP" protocol="http"> <provider>ABCD</provider> <urlRewrite>/service/xyz/getAccountDetails</urlRewrite> <timeout>30</timeout> </endPoint> </Service> <Service> <endPoint... (3 Replies)
Discussion started by: abhilwa
3 Replies

8. Shell Programming and Scripting

How can I remove some xml tag lines using shell script?

Hi All, My name is Prathyu and I am working as a ETL develper. I have one requirement to create a XML file based on the provided XSD file. As per the Datastage standards Key(repeatable) field does not contain any Null values so I am inserting some dummy tag line to that XML file. ... (14 Replies)
Discussion started by: Prathyu
14 Replies

9. UNIX for Advanced & Expert Users

Shell Script to read XML tags and the data within that tag

Hi unix Gurus, I am really new to Unix Scripting. Please help me to create a shell script which reads the xml file and from that i need to fetch a particular information. For example <SOURCE BUSINESSNAME ="" DATABASETYPE ="Teradata" DBDNAME ="DWPROD3" DESCRIPTION ="" NAME... (2 Replies)
Discussion started by: SmilePlease
2 Replies

10. Shell Programming and Scripting

How to remove some xml tag lines using shell script

I have existing XML file as below, now based on input string in shell script on workordercode i need to create a seprate xml file for e.g if we pass the input string as 184851 then it find the tag data from <workOrder>..</workOrder> and write to a new file and similarly next time if i pass the... (3 Replies)
Discussion started by: balrajg
3 Replies
Login or Register to Ask a Question