From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3741 invoked by alias); 22 Oct 2013 17:11:27 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18045 Received: (qmail 9857 invoked from network); 22 Oct 2013 17:11:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 Message-ID: <1382461534.20462.9.camel@air.home.fifi.org> Subject: Re: Glob problem From: Philippe Troin To: Brent Briggs Cc: zsh-users@zsh.org Date: Tue, 22 Oct 2013 18:05:34 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.5 (3.8.5-2.fc19) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit 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.