[oclug] changing suffix

Jean Richard jean at geemoo.ca
Mon Jun 14 18:31:55 EDT 2010


>> I am trying tro change the suffix of files that end in .a.b to .b
>> I tried (to echo first):
>> for f in *\.a\.bl; do echo ${f#\.a\}.b; done
 > This may not be the cleanest way, but here is a script that will change
 > them...

Check out the rename utility (found in the perl package on debian)

{jean at lithium} ls
foo1.a  foo2.a  foo3.a
{jean at lithium} rename "s/$/.b/" *.a
{jean at lithium} ls
foo1.a.b  foo2.a.b  foo3.a.b

The first argument is the regex command that describes the change that 
you want to make.. (dig up rgb's oclug talk on regex's or search google 
for info).  The rest of the arguments are the files that you want to rename.

--
Jean


More information about the OCLUG mailing list