Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: filename expansion problem
- X-seq: zsh-users 11371
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: <zsh-users@xxxxxxxxxx>
- Subject: Re: filename expansion problem
- Date: Mon, 02 Apr 2007 21:06:28 -0700
- In-reply-to: <20070403114154.1976@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070403114154.1976@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
On Apr 3, 11:41am, djh wrote:
}
} What is the trick to enable me to use wild cards withing the
} conditional [[ ]]
There is no trick. Wildcards in [[ ]] are treated as patterns to be
matched against other strings, not against file names. E.g.
food=fodder
if [[ $food = *odd* ]]; then ...
You couldn't do that if the *odd* expanded into a file name first.
If you want file names expanded, use [ ] as in
if [ -e file-name-*.tar.bz2 ] ; then print hello ; fi
However, that will usually cause an error if the pattern expands to
more than one file, so you might want to use
if [ -e file-name-*.tar.bz2([1]) ]; then ...
Replace ([1]) with ([0]) if you have the ksh_arrays option set.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author