Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Expanding when matching
- X-seq: zsh-users 7401
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Expanding when matching
- Date: Fri, 23 Apr 2004 15:05:32 -0700
- In-reply-to: <20040423211540.GA1821@DervishD>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20040423211540.GA1821@DervishD>
On Fri, Apr 23, 2004 at 11:15:40PM +0200, DervishD wrote:
> $ testvar="This is my test var"
> $ print ${testvar/var%/Replaced}
> This is my test var
This should be:
$ print ${testvar/%var/Replaced}
This is my test Replaced
The leading '%' indicates that the match must occur at the end.
> What I want is the substitution (and the postincrement) expanded and
> run only when the parameter matches
If you don't need it done in a single line, you can always use "case":
counter=0
for number in {1..100}; do
case $number in
*0) print "Hit a ten! $((counter++))" ;;
*) print $number ;;
esac
done
..wayne..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author