Traduisez - Übersetzen - Traduzca - Traduza - Tradurre - Translate

Re: quick shell question

Christian Nally (nally@physics.ubc.ca)
Sat, 21 Mar 1998 11:16:17 -0800 (PST)

> And now I ended up with a whole lot of files like
> 'filename.cpp.cc'! How can I remove the '.cpp' element
> out of all the files in one shot so that it is just
> 'basename.cc'?

Here's a perl script I whipped up. I'm sure there is a more general
implementation of this. This seems to work fine for the present problem.
:)

#!/usr/bin/perl

@files = glob("*.cpp.cc");

foreach $file (@files) {
$oldfile = $file;
$file =~ s/.cpp.cc/.cc/;
exec "mv $oldfile $file";
}