pattern matching rename...

bruce bedouglas at earthlink.net
Fri Dec 29 15:03:00 UTC 2006


hi todd..

in the words of someone else.. "doh!!" i had interpreted the initial "." in
the rename . _foo. ABCcat.*  as a dir, as opposed to something in the
placement function.. makes sens now..

thanks


-----Original Message-----
From: fedora-list-bounces at redhat.com
[mailto:fedora-list-bounces at redhat.com]On Behalf Of Todd Zullinger
Sent: Thursday, December 28, 2006 6:08 PM
To: fedora-list at redhat.com
Subject: Re: pattern matching rename...


bruce wrote:
> $ rename . _dog. abcCAT.*
>  ls abcCAT*
> abcCAT_dog.py  abcCAT_dog.txt
>
> this works. but i can't find any docs that give a good explanation
> of how/why this works.

The rename command in Fedora comes from the util-linux package.  It
doesn't use regular expressions.  It just does basic string matching.

> it appears that the rename is taking the "_dog" and adding it to the
> "abcCAT"... but how would i know that this is going to occur.. is
> this really what's going on.. what if i wanted to have the "_dog"
> added before the abcCAT...

The command usage is

    rename from to files

from and to are strings.  In the example, the from string is '.' and
the to string is '_dog.'.  So for all of the files given as the third
argument, '.' is replaced with '_dog.'.

> i was also under the impression that 'rename' could use regex's but
> i can't figure out how..

There are other rename programs that do work this way.  It's annoying
if you switch between such systems and find out that rename doesn't
behave like you're expecting. :)

--
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
======================================================================
We must all hang together, or assuredly we shall all hang separately.
    -- Benjamin Franklin, upon signing the Declaration of Independence





More information about the fedora-list mailing list