[Nottingham] A little scripting on a Sunday evening (help please)

Dean Sas dean at deansas.org
Sun Apr 9 20:17:11 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joshua Lock wrote:
> On 9 Apr 2006, at 19:49, Roger Light wrote:
>> On 09/04/06, Michael Simms <michael at tuxgames.com> wrote:
>>
>>> cat $1 | sed -e "s/\.html/\.php/g" > /tmp/fixing
>>> mv /tmp/fixing $1
>>
>> If you've got a decent sed (gnu sed is fine, sun sed ain't, you should
>> be able to do
> 
> I don't think I have a decent sed
> 
> "sed: -i may not be used with stdin"
> 
>> sed -i $1 "s/\.html/\.php/g"
>>
>> -i does editing in place of a file.

To do this in perl would be nearly identical I think.

perl -pi -e 's/\.html/\.php/g' *

This should fix everything in the current working directory, I'd guess
it's easy to get perl to recurse into different directories.

It's probably best to take a backup of the directory first though tbh.

Dean
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEOV2ueedO8dcp9nYRAjeHAJ9AAuhrkzen6+Gw1+4Jtu1pVzPE4gCcDIvJ
pe0Uf/2B9zXp7DHtHcnv/OU=
=zyv8
-----END PGP SIGNATURE-----



More information about the Nottingham mailing list