here is my question , im using ubuntu , and im trying to replaces text in a xml file .. from a txt that i have all changes that i made ,an example
in replace.txt file i have this
nameofsearch | nameforreplace
nameofsearch1 | nameforreplace1
nameofsearch2 | nameforreplace2
this is the format that the software uses for search and replace
and on the xml file, i have the nameofsearch
this was done by a soft made on .net, that i can’t run on linux , so this is my question , how can i do that , using bash , or any other thing like that.
thanks , sebastian.
The tool you are looking for is sed. If you want to replace str1 with str2 in file1 and save the result in file2, run:
You need to escape some special characters because sed parses the str1 as a regular expression.
In your case, two steps are needed. The first step transforms your
replace.txtinto a sed script file witch I callreplace.sed.The first sed call transforms your pipes (and surrounding whitespaces) into slashes
|->/. The second call surrounds your search/replace strings with sed syntax.replace.sedshould look likeThe second step is to execute sed with the given script file on your xml file.