From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17097 invoked by alias); 10 Jun 2014 06:27:04 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18894 Received: (qmail 13991 invoked from network); 10 Jun 2014 06:26:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Tue, 10 Jun 2014 08:17:18 +0200 From: Roman Neuhauser To: "William G. Scott" Cc: zsh-users@zsh.org Subject: Re: regular expressions and setting variables? Message-ID: <20140610061718.GA96641@isis.sigpipe.cz> References: <157E3510-D220-4C1C-A452-93DE96DA4363@chemistry.ucsc.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <157E3510-D220-4C1C-A452-93DE96DA4363@chemistry.ucsc.edu> User-Agent: Mutt/1.5.23 (2014-03-12) # wgscott@ucsc.edu / 2014-06-09 22:04:20 -0700: > I?m trying to emulate how iTunes changes some names of directories it > creates based on names of artists. For example, albums by the group > R.E.M. are stored in a directory it creates called R.E.M_ > > The final full-stop is replaced with an underscore, I assume to avoid > complications in the unix filesystem. i doubt that. "the unix filesystem" does not care about names at all, well, almost: a filename cannot contain slashes and null bytes. slash, because these are used to separate "foo" from "bar" in "foo/bar", and null bytes, because "foo" and "bar" are stored in the filesystem as C strings, where the null byte is used as terminator. windows filesystems OTOH, among other limitations, prohibit names ending with a dot. > This works: > > JUNK=R.E.M. > print ${JUNK}| perl -p -e 's|\.$|_|g? > > It returns > R.E.M_ > > > But if I try to do this: > > print ${JUNK/\.$/_} > > it returns > R.E.M. > > I assume I am not using the correct regexp. kinda, the ${param/pat/rep} operation does not use regexps, the pattern expects the globbing ("filename generation") syntax. > What do I need to do to get this working? man zshexpn. -- roman