From owner-freebsd-questions@FreeBSD.ORG Tue Dec 16 18:47:16 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EB966328 for ; Tue, 16 Dec 2014 18:47:16 +0000 (UTC) Received: from mail-wi0-x230.google.com (mail-wi0-x230.google.com [IPv6:2a00:1450:400c:c05::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7B2BAAF2 for ; Tue, 16 Dec 2014 18:47:16 +0000 (UTC) Received: by mail-wi0-f176.google.com with SMTP id ex7so13269357wid.3 for ; Tue, 16 Dec 2014 10:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=X9aSRC8xeZ+b29LRgcOdyuLDxPCh4L5c00xgGDWx0hw=; b=GPeNCkCkf1mGIxADBkHzj9FFfsPST2NJlO1EZGR5EBqnG8PfJ77/P2W1DE4RTQUyUA eMzZubyhQts24gZqFbtaZf4bgptRCo2OfbQXJvzTjk/wau4V2J3NRYtjjjHwC+oBdv9o WsII+NPHz8bYkv2RW15v9Ty0H2ZAgsXjSGPJLoWBlskCxWqrw/in6GZY0qziyrFm/QwY IIzJSeB7f03Y902vP76FnxWdbvtHHQbaDyAv/n0UrOBVE4VD936hfY3egqPnaissETY6 fDlrOT0B1xWMbAax7hJZDeU3XdV5UKiuX+RcSeozkJoEE9WFDOmtx2+b7ZIFAjjSuFlr WzRg== X-Received: by 10.180.85.4 with SMTP id d4mr7251180wiz.36.1418755634967; Tue, 16 Dec 2014 10:47:14 -0800 (PST) Received: from DaemON.home (90-156-31-193.internetia.net.pl. [90.156.31.193]) by mx.google.com with ESMTPSA id eu15sm3135127wid.18.2014.12.16.10.47.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Dec 2014 10:47:14 -0800 (PST) Date: Tue, 16 Dec 2014 19:46:01 +0100 From: Serpent7776 To: freebsd-questions@freebsd.org Subject: Re: Perl rename utility assistance Message-ID: <20141216194601.23bdcc7f@DaemON.home> In-Reply-To: <54907B51.1060807@gmail.com> References: <54907B51.1060807@gmail.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; amd64-portbld-freebsd9.3) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Jungle Boogie X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2014 18:47:17 -0000 Hello, On Tue, 16 Dec 2014 10:34:57 -0800 Jungle Boogie 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