Perl rename utility assistance

Serpent7776 serpent7776 at gmail.com
Tue Dec 16 18:47:17 UTC 2014


Hello, 

On Tue, 16 Dec 2014 10:34:57 -0800
Jungle Boogie <jungleboogie0 at gmail.com> wrote:

> Hello All,
> 
> I figure I would try my luck here with this question. Usually I go to 
> stackoverflow for these things so pardon the noise if you're not accustom to 
> seeing letters like this.
> 
> Objective: remove an underscore from a filename using rename[0].
> Example: 8213_freebsd_is_cool_Nov_2014.pdf
> 
> I only want to remove the underscore (_) between the 3 and f to make it:
> 8213 freebsd_is_cool_Nov_2014.pdf
> or
> 8213 _freebsd_is_cool_Nov_2014.pdf
> 
> rename '-sr/^([:digit:]_) /^[:digit:] /g' *
> rename '-s/^[:digit:]_/^[:digit:] /g' *
> rename '-sr/^[:digit:]_/^[:digit:] /g' *

Try this:

rename '-s/_/ /' 8213_freebsd_is_cool_Nov_2014.pdf

Don't use g modifier is you want only replace first occurence of pattern.

-- 
//Serpent7776


More information about the freebsd-questions mailing list