Unix Shell Loop through files and replace texts

I am fairly new to this stuff, and I need a shell file to loop through all “.xml” files in a folder, and do some text replacements.
So far I have come up with this:

sed "s/old_text/new_text/g" testfile.xml -i

However, I want this to run on all xml files in the current folder, not just on “testfile.xml”. Furthermore, how can I make a backup of the original file ?

Any input is more than welcomed!
Thankls a lot!

Source: shell

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.