Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Help on filename generation
- X-seq: zsh-users 11602
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Help on filename generation
- Date: Tue, 10 Jul 2007 18:53:17 +0100
- In-reply-to: <87r6nggnrv.fsf@xxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <87r6nggnrv.fsf@xxxxxxxxxxxxxxxxxxxxxxxx>
Joel J. Adamson wrote:
> function doit() {
> for file in $1/*(generic)*~*(~)
> print $file
> exit
> }
>
> Currently I get "doit:1: unknown file attribute." When I enter this
> globbing pattern at the interactive prompt, I get the files I want.
The pattern should be:
$1/*generic*~*\~
The parentheses around the final tilde were confusing it.
You don't need the backslash near the end as a final ~ is a special
case, but it makes it more obvious.
It doesn't matter in this case, but as it happens the pattern after the
first "~" is matching against the entire string, including the
directory. In other words, for everything that matches $1/*generic* it
sees if that entire string matches *\~ and if so rejects it. That would
become important if you wanted to match some earlier component in the
final part of the path.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview
Messages sorted by:
Reverse Date,
Date,
Thread,
Author