[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about patterns

From: Chet Ramey
Subject: Re: Question about patterns
Date: Thu, 23 Jun 2011 11:08:13 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10

On 6/23/11 9:59 AM, Steven W. Orr wrote:
> I may be wrong, but I think there's a way to do what I want without using a
> regex.
> I have a file called foo-1.2-3.tar.gz
> I need to set a variable equal to
> foo-1.2-i386-x86_64-3.tar.gz
> Is there a way to do this without parsing my brains out? I am facile with
> the variable operations like # ## % %% and /, but what I really want to do
> is to say something like
> bar=${foo/-([1-9]).tar.gz/-i386-x86_64-\1.tar.gz}
> where the \1 is some sort of thing that I can use to refer to a backref.
> Does this exist in bash or do I just do it with a regex?

Bash pattern substitutions are simple strings, not regular expressions.
They do not have backreferencing.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]