[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [debian-user] OT: Wildcard renaming of files

=?iso-8859-1?Q?R=FCdiger_Kuhlmann?= <replyto-nqXRTuTQ74dn@ruediger-kuhlmann.de> wrote:
>--[Martin Fluch]--<fluch@rock.helsinki.fi>
>> A little bit bash programming...
>> for $i in *.html ; do mv "$i" "${i:0:${#tmp}-1}" ; done
>for $f in *.html; do mv $f ${f/.html/.htm}; done
>Requires a not too old bash. Beware of file names containing .html
>elsewhere than at the end...

That's what the % flag solves (match only at the end), when put
immediately after the first / (so ${f/%.html/.htm}). The # flag does the
same thing for matching only at the beginning. This is especially useful
for moving entries around in your $PATH and similar environment

Colin Watson                                     [cjw44@flatline.org.uk]

Reply to: