search and replace string on multiple files from unix terminal
Try this:
find . -name '*.html' -exec sed -i 's/\.html/\.php/g' "{}" \;
It will find all files in the current and subdirectories that end in .html
, and run sed
on each of them to replace .html
with .php
anywhere it appears within them.
See http://content.hccfl.edu/pollock/unix/findcmd.htm for more details.