In Place search and replace with Perl on Windows
We had to do a massive restructuring of one of our client’s applications and it required changes to the domain names and URL’s.
The command below will replace occurrences of www.infoexport.gc.ca/ie-en with www.tradecommissioner.gc.ca/eng in html files recursively. The \ is used to escape / in the URL’s.
If you are running this on Windows you HAVE to specify a backup file name using the -i parmeter. This is a limitation of the Windows file system, the side effect being its always good to have backups.
$ find . -type f | xargs perl -p -i’test.bak’ -e ’s/www.infoexport.gc.ca\/ie-en/www.tradecommissioner.gc.ca\/eng/g’ *.html
No comments yet
Leave a reply