modifying xml files using sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting modifying xml files using sed
# 1  
Old 07-06-2009
modifying xml files using sed

Hello,

I have lots of xml files in the same format and I need to modify a xml tag in these files.
i loop over the files and apply sed to the files to make the modification but CPU goes to %100 while doing this. I think I'm doing something wrong. Here is my onliner:

Code:
for f in $( find . -name "*.xml" ); do sed -n "s/<idle>600<\/idle>/<idle>900<\/idle>/p" $f >> $f;   echo "file:" $f;done

by the way, I use Linux sed, not Unix sed.(I'm not sure if differs)

thanks in advance...
# 2  
Old 07-06-2009
The problem is with this line. You cannot send the output of GNU sed to itself.
Code:
sed -n "s/<idle>600<\/idle>/<idle>900<\/idle>/p" $f >> $f

You could use the -i option to edit it in place. man sed for more information.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Splitting a single xml file into multiple xml files

Hi, I'm having a xml file with multiple xml header. so i want to split the file into multiple files. Sample.xml consists multiple headers so how can we split these multiple headers into multiple files in unix. eg : <?xml version="1.0" encoding="UTF-8"?> <ml:individual... (3 Replies)
Discussion started by: Narendra921631
3 Replies

2. Shell Programming and Scripting

Splitting xml file into several xml files using perl

Hi Everyone, I'm new here and I was checking this old post: /shell-programming-and-scripting/180669-splitting-file-into-several-smaller-files-using-perl.html (cannot paste link because of lack of points) I need to do something like this but understand very little of perl. I also check... (4 Replies)
Discussion started by: mcosta
4 Replies

3. Shell Programming and Scripting

Extract strings from XML files and create a new XML

Hello everybody, I have a double mission with some XML files, which is pretty challenging for my actual beginner UNIX knowledge. I need to extract some strings from multiple XML files and create a new XML file with the searched strings.. The original XML files contain the source code for... (12 Replies)
Discussion started by: milano.churchil
12 Replies

4. Shell Programming and Scripting

Compare two xml files while ignoring some xml tags

I've got two different files and want to compare them. File 1 : <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record id="38,557"><columns><column><name>orge... (2 Replies)
Discussion started by: Shaishav Shah
2 Replies

5. Shell Programming and Scripting

Modifying sed to only change last occurrence.

I'm using sed to switch integers (one or more digits) to the other side of the ':' colon. For example: "47593:23421" would then be "23421:47593". The way it functions right now, it is messing my settings file to use with gnuplot. The current command is: sed 's/\(*\):\(*\)/\2:\1/' out3 >... (3 Replies)
Discussion started by: D2K
3 Replies

6. Shell Programming and Scripting

Help with modifying files

Hello everyone, I have some data files, with mixed header formats. the sample for the same is: >ABCD76567.x1 AGTCGATCGTAGTCGTAGCTGT >ABCD76567.y1 AGTCGATCGTAGTCGTAGCTGT >ABCD76568.x1 pair_info:898989 AGTCGATCGTAGTCGTAGCTGT >ABCD76568.y1 pair_info:893489 AGTCGATCGTAGTCGTAGCTGT... (2 Replies)
Discussion started by: ad23
2 Replies

7. Shell Programming and Scripting

Modifying XML document with Unix Script

Hi, I have xml documents that I want to change a value in, I can do it using sed in a text document but not the xml document. I have read other posts that allow the change between tags but the part I wish to change is only a small part of data with the tags. e.g. <?xml version="1.0"... (2 Replies)
Discussion started by: heather.morton@
2 Replies

8. UNIX for Dummies Questions & Answers

Modifying a file using SED

Dear Members, I have a file which contains data as shown below: LOAD DATA APPEND INTO TABLE xxap.test ( RAW_DATA char(3000) "replace(:raw_data,'*','|')", LOADING_SEQUENCE "xx_gl_bank_fee_s1.nextval", CREATION_DATE SYSDATE, LAST_UPDATE_DATE SYSDATE, ATTRIBUTE1 "DATE_STAMP", ... (1 Reply)
Discussion started by: sandeep_1105
1 Replies

9. Shell Programming and Scripting

using sed with xml files part 2

I'm trying to replace a date in an XML file that has the format mm/dd/yyyy. I'm using the Unix date function to set up a variable with the current date but, when I try to replace the value in the XML file, the error message says it cannot be parsed. Here is the command I'm using ... (2 Replies)
Discussion started by: stonemonolith
2 Replies

10. Shell Programming and Scripting

using sed with xml files

Hello I'm working on a project modifying XML files in Unix and, I would like to use sed to change these values. For example, I've got a tag <book>354678209<\book> and I want to replace the value 354678209 with a another value without having to go into the file and change it manually. How can I do... (3 Replies)
Discussion started by: stonemonolith
3 Replies
Login or Register to Ask a Question