Help with search and delete/add/modify script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with search and delete/add/modify script
# 1  
Old 08-06-2009
Help with search and delete/add/modify script

Gurus,

I need to run a script on multiple XML files in different directories and do the following (the output can be redirected to create a new file)

1. Search a pattern like "abc.mno.xyz" in an XML file, once detected, the script should delete one line above and 3 lines below (including the line containing the pattern)

So the following pattern should just disappear from the text file on which I will run this script

<option>
<name>abc.mno.xyz</name>
<value>true</value>
</option>

2. Update the following fragment in the XML file

<options>
<option>
<name>addAllRoles</name>
<value>true</value>
</option>
</options>


to the following (it changes one of the value from true to false and adds an additional xml tag)

<options>
<option>
<name>addAllRoles</name>
<value>false</value>
</option>
<option>
<name>addRoles</name>
<value>false</value>
</option>
</options>
# 2  
Old 08-07-2009
Have you looked xml tools (some xslt), stylesheet, ... they are usually the best for xml manipulation ?
# 3  
Old 08-09-2009
Just post the input and the desired output.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pattern search and modify the values

I have one file and the file may contain 500 to 15,000 records. I need to search pattern ^F509= and then increment the corresponding value by one and print the entire line. Please note that Its not a fixed length file. Can anyone please help? ex: ^F509=204656 ^F509=204656 ... (6 Replies)
Discussion started by: vinus
6 Replies

2. Shell Programming and Scripting

Find modify and delete files

hi every one. one of my friends has writen this script and send it to me. this script can find files that add-delete-modify and also send an alert by email i'm not catch all part of it. can anyone explain me how this work #!/bin/bash START="a.txt" END="b.txt" DIFF="c.txt" mv ${START}... (4 Replies)
Discussion started by: nimafire
4 Replies

3. Shell Programming and Scripting

Help on Script of line delete and add

Hey guys , I want create one script which give below output form my input: Input file A ABC12 122 ABC12 -0.7 ABC12 126 ABC12 0.0 ABC12 1210 ABC12 -0.7 ABC12 128 ABC12 17.3 ABC12 120 ABC12 21.9 ABC12 124 ABC12 19.5 ABC23 131 ABC23 130 ABC23 122 (4 Replies)
Discussion started by: pareshkp
4 Replies

4. Shell Programming and Scripting

Conditional search and delete using SED / Shell script

Hi, I want to perform a conditional search and remove my search string. Input string: "abcdaabcadgfaarstab" Character to search: "a" Condition: Remove all "a" in the input string except if it is "aa" Output string: "bcdaabcdgfaarstb" Can you please help me in this? (5 Replies)
Discussion started by: dominiclajs
5 Replies

5. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

6. Shell Programming and Scripting

shell script to search a string and delete the content

Hi, I've a shell script e.g. #!/bin/bash echo "Enter the next hop id" read nhid echo "enter the IP address" read IP echo "enter the interface name" read name echo "enter the enable/disable state" read state exit 0 now from this script i want to search strings in another (.cam) ... (6 Replies)
Discussion started by: vic_mnnit
6 Replies

7. UNIX for Dummies Questions & Answers

modify a particular pattern starting from second line of the search pattern

Hi, I think you ppl did not get my question correctly, let me explain I have 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: ... (1 Reply)
Discussion started by: imas
1 Replies

8. UNIX for Dummies Questions & Answers

modify a particular pattern starting from second line of the search pattern

Hi, I am new to this forum and i would like to get help in this issue. I have a file 1.txt as shown: apple banana orange apple grapes banana orange grapes orange .... Now i would like to search for pattern say apple or orange and then put a # at the beginning of the pattern... (2 Replies)
Discussion started by: imas
2 Replies

9. Shell Programming and Scripting

add or modify if existent

I want to set these params in /etc/system set shmsys:shminfo_shmmax=2000000000 set shmseg:shminfo_shmseg=200 if this param exists, then I want to modify them if not, I want to add them. I can add them using >>/etc/system but how to do the modify thing? at least I can comment the... (4 Replies)
Discussion started by: melanie_pfefer
4 Replies

10. Shell Programming and Scripting

how can i add/modify filename after output?

Hi All, I have a script to convert a file and output the filename with "_output", however it not work. Can help? echo Please input list file name: read listn for file in `cat $listn.txt` do convert $file > $file_output Thanks all!! (3 Replies)
Discussion started by: happyv
3 Replies
Login or Register to Ask a Question