Thingy Ma Jig is the blog of Nicholas Thompson and contains any useful tips, sites and general blog-stuff which are considered interesting or handy!
Posted on 26 May 2009 in
tip
linux
How to
bash
After Worldpay recently changed to use the RBS system, I was tasked with finding every instance of select.worldpay.com/wcc/purchase
in our forms and replacing it with select.wp3.rbsworldpay.com/wcc/purchase
. There appeared to be thousands of files and I wasn't going to do it manually…
A quick google later and I found that you can easily use a combination of Grep (to find the files) and sed (a text stream editor) to change the content. Notice how in sed, the find and replace strings have to have the forward slash escaped as we're using it as delimiter.
grep "select.worldpay.com/wcc/purchase" . -Rl | xargs sed -i 's/select.worldpay.com\/wcc\/purchase/select.wp3.rbsworldpay.com\/wcc\/purchase/g'
This probably isn't perfect - but it did the job for me and I hope it helps anyone else that stumbles upon it :)