Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Dec 2014 19:46:01 +0100
From:      Serpent7776 <serpent7776@gmail.com>
To:        freebsd-questions@freebsd.org
Cc:        Jungle Boogie <jungleboogie0@gmail.com>
Subject:   Re: Perl rename utility assistance
Message-ID:  <20141216194601.23bdcc7f@DaemON.home>
In-Reply-To: <54907B51.1060807@gmail.com>
References:  <54907B51.1060807@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello, 

On Tue, 16 Dec 2014 10:34:57 -0800
Jungle Boogie <jungleboogie0@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141216194601.23bdcc7f>