Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Glob problem
On Tue, 2013-10-22 at 12:45 -0400, Brent Briggs wrote:
> I am simply trying to list all matches for a specified pattern in an
> array of directory paths, the $path array for example. Here is my
> attempt. Where am I going wrong?
Globs are not ran after variable substitution by default.
To run filename generation (aka globs) after variable substitution, use
$~var.
Your example:
> pattern=git*
> for entry in $path
> do
> # Print all files in the path that match the pattern.
> print $entry/$pattern
> done
Can be rewritten as:
pattern=git*
for entry in $path
do
# Print all files in the path that match the pattern.
print $entry/$~pattern
done
It can be simplified further as:
pattern=git*
print $path/$~pattern
Phil.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author