From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6548 invoked by alias); 24 Oct 2011 13:45:14 -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: 16537 Received: (qmail 29521 invoked from network); 24 Oct 2011 13:45:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at m.gmane.org designates 80.91.229.12 as permitted sender) X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: zsh-users@zsh.org To: zsh-users@zsh.org From: Stephane CHAZELAS Subject: Re: checking for file existence when I don't know the exact name Date: Mon, 24 Oct 2011 13:35:37 +0000 (UTC) Message-ID: References: X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 188-223-3-27.zone14.bethere.co.uk Mail-Copies-To: nobody User-Agent: slrn/pre1.0.0-18 (Linux) 2011-10-24, 09:16(-04), TJ Luoma: > I want to check to see if a file exists that matches this pattern: > > OmniFocus-XXXXX.omnilicense > > where XXXXX is some set of numbers of an unknown length. > > I've been using > > ls | egrep -q "OmniFocus.*\.omnilicense" > > but it occurs to me that I might be able to use [[ -e ]] > > However, I'm not sure what the syntax is. I tried: > > if [[ -e "OmniFocus.*.omnilicense" ]] > then > > {take action here} [...] matching_files=(OmniFocus.<->.omnilicense(N)) if (($#matching_files)); then... -- Stephane