Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Expansion, matching, files



Hi,

I'm playing with something that is bugging me...

I want to find if a file exists either ff.log or ll.log for example

Now to do this with pattern maching is easy:

I create my file for example
 touch ff.log
 ll *log
-rw-r--r-- 1 jro softdev 0 Nov 12 10:40 ff.log

for f in *
do
[[ $f == (ff|ll).log ]] && echo Yes
done
Yes

This also works of course:

 print (ff|ll).log
ff.log


But I would like to do this:

[[ -e (cc|ff).log ]] && echo yes
zsh: parse error near `('

Can I use this kind of pattern in an if statement ?

NOTE: I know I could do [[ -e ff.log || -e ll.log ]] && echo yes

But that would not be fun nor simple to type if for example you wanted to test ([a-z][5-6]).log

Thanks in advance,

Jerry






Messages sorted by: Reverse Date, Date, Thread, Author