471,318 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,318 software developers and data experts.

Using Regular Expresions to change .htm to .php in files

Hi,

I have a bunch of files that have changed from standard htm files to
php files but all the links inside the site are now broken because
they point to the .htm files while they are now .php files.

Does anyone have an idea about how to do a simple script that changes
each .htm in a given file to a .php

Thanks a lot in advance

Aug 23 '07 #1
2 848
se****@gmail.com wrote:
Hi,

I have a bunch of files that have changed from standard htm files to
php files but all the links inside the site are now broken because
they point to the .htm files while they are now .php files.

Does anyone have an idea about how to do a simple script that changes
each .htm in a given file to a .php

Thanks a lot in advance
#!/bin/bash

for each in *.php; do

sed "s/.htm/.php/g" < $each /tmp/$$
mv /tmp/$$ $each
done
--
Posted via a free Usenet account from http://www.teranews.com

Aug 25 '07 #2
On Thu, 23 Aug 2007 12:27:10 -0700, Tobiah wrote:
sed "s/.htm/.php/g" < $each /tmp/$$
This line should be:

sed "s/\.htm$/.php/g" < $each /tmp/$$

Aug 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Varun Singal | last post: by
5 posts views Thread by NickName | last post: by
1 post views Thread by Kenny M. | last post: by
5 posts views Thread by Josema | last post: by
21 posts views Thread by James Black | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.