0

i have several php files, and there's references to .html files in those.

I need to replace ".html" to ".php"

how can i do this in bash ?

1
  • 2
    You'll probably want to double-check the results of this. You wouldn't want, for example, an external link to another *.html file that's a legitimate link to be renamed to PHP. Commented Jan 2, 2010 at 2:43

4 Answers 4

2
for file in $(find . -name "*.php"); do
    sed "s/\.html/.php/g" $file > $$ && mv $$ $file
done
Sign up to request clarification or add additional context in comments.

Comments

1
find -name '*.php' -exec sed -ie 's:.html:.php:g' {} \;

Comments

0

Try sed:

find -name "filenamepattern.php" -print0 | xargs -0 sed 's/\.html/\.php/g'

Comments

0

GNU find

find /path -type f -iname '*.php' -exec sed -i.bak 's/\.html/\.php/g' {} +;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.