Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Replacing incremntal string in file
Name: samarjith Date: January 8, 2009 at 10:38:06 Pacific OS: Windows 2000 CPU/Ram: Intel(R) Pentium(R) M processor 2.00 GHz Product: Ibm / T43 Subcategory: Software Problems
Comment:
we recieve a xml file daily....that has the following info.
Now I want to replace the Image1,Image2,Image3 tags with Image. In the original file it can be any like Image1...Image10000. so I need to replace all the tags to Image. And there will be 5000 files every day to be processed like this. Can anybody help me in fixing this? Thanks in advance.
Name: nails Date: January 8, 2009 at 11:16:43 Pacific
Reply:
Here is the hard part, replacing the tags:
sed -e 's/^<Image[0-9]*/<Image/' -e 's/^<\/Image[0-9]*/<\/Image/' myfile.xml
0
Response Number 2
Name: samarjith Date: January 8, 2009 at 13:04:36 Pacific
Reply:
above solution is working if the xml file is indented. My files are not indented....from first to last they are on one line. I tried the above solutions on unindented files, but it is not working. Please provide me the solution for an unindented file.
Thanks
Samar
0
Response Number 3
Name: nails Date: January 8, 2009 at 21:11:21 Pacific
Reply:
sed -e 's/<Image[0-9]*/<Image/g' -e 's/<\/Image[0-9]*/<\/Image/g' myfile.txt
Summary: I need to create a script, taking a number of parameters (a target string, a string to replace the target string, and a number of files), that performs the substitution and a backup file creation whe...
Summary: The short story is I want to find a string in a file and change it. Here are the details. I'm looking for a way to change every occurence of $source to "JavTemp" in a file called JavTemp2.java. $so...