473,480 Members | 2,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 890
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2037
by: Tony C | last post by:
I'm writing a python program which uses regular expressions, but I'm totally new to regexps. I've got Kuchling's "Regexp HOWTO", "Mastering Regular Expresions" by Oreilly, and have access to...
2
4387
by: Varun Singal | last post by:
Hi I am calling .NET components from my Classical ASPs. For this I strong named my assemblies, then registered them in the resistry ( using RegAsm), and put them in GAC (using GacUtil) ....
43
2560
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
5
1463
by: NickName | last post by:
I need to remove all the in every sql stmt where they are used to close encircling numeric value, fyi, all these sql stmt are converted from an Access db. For instance, select * from XYZtbl...
1
998
by: Kenny M. | last post by:
Where can I learn to write Regular Expresions e.g. I need to validate the time format HH:mm a.m. it look simple. I want to use a regularExpression validator but It seem complicated to write...
5
1827
by: Josema | last post by:
Hi to all, i did this regular expresion <!--!.*!--> that matchs all occurrences of type <!--!Name!--> <!--!Description!--> and so on... I would like to know the regular expression to get...
21
39433
by: James Black | last post by:
I am curious if there is a benefit to set attributes directly, in my javascript, or to use setAttribute. For example, I have this: var input = document.createElementNS(xhtmlNS, 'input');...
4
3668
by: jpluttme | last post by:
I need to replace not just the ASC or DESC but the value it's sorting by. i.e. in a string like this: http://www.mysite.com/page1.php?value=uservalue1&sort=ORDER+BY+uservalue1+DESC I've not had...
0
6915
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7097
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6750
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4493
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3003
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
567
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.