[wplug] Slightly off topic...shell script
Eric C. Cooper
ecc at cmu.edu
Fri Feb 11 17:17:11 EST 2005
On Fri, Feb 11, 2005 at 02:11:24PM -0800, Dileep Vangasseri wrote:
> I have a set of files having names which has
> characters --- in between (like foo---test--to.txt). I
> want to replace '---' with a '-' (single dash). Can
> anyone suggest a script which would make my life
> simple?
>
> I tried:
>
> for i in *.txt; do mv "$i" `echo $i | tr '---' '-'`;
> done
On Debian, at least, the standard Perl package contains the
"rename" command. With it, you can do
$ rename 's/---/-/g' *.txt
as well as much fancier things, since the first arg is an arbitrary
Perl expression.
--
Eric C. Cooper e c c @ c m u . e d u
More information about the wplug
mailing list