From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17901 invoked from network); 3 Sep 2005 19:07:23 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Sep 2005 19:07:23 -0000 Received: (qmail 15447 invoked from network); 3 Sep 2005 19:07:17 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Sep 2005 19:07:17 -0000 Received: (qmail 2024 invoked by alias); 3 Sep 2005 19:07:10 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9380 Received: (qmail 2012 invoked from network); 3 Sep 2005 19:07:09 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 3 Sep 2005 19:07:09 -0000 Received: (qmail 14397 invoked from network); 3 Sep 2005 19:07:09 -0000 Received: from spatula.dreamhost.com (66.33.205.9) by a.mx.sunsite.dk with SMTP; 3 Sep 2005 19:07:01 -0000 Received: from [192.168.1.9] (unknown [68.250.189.88]) by spatula.dreamhost.com (Postfix) with ESMTP id 72CCA17D02F for ; Sat, 3 Sep 2005 12:06:56 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v734) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Timothy Luoma Subject: Re: trying to match yyyy-mm-dd what am I missing? Date: Sat, 3 Sep 2005 15:06:54 -0400 To: zsh-users@sunsite.dk X-Mailer: Apple Mail (2.734) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.0.4 On Sep 3, 2005, at 9:04 AM, Geoff Wing wrote: > Timothy Luoma typed: > : I am trying to match all folders in the CWD which are in the format > : YYYY-MM-DD. > : if [ "$i" = 2[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] ] > > This gets expanded to all the directories matching it. See > "CONDITIONAL EXPRESSIONS: .... > Normal shell expansion is performed on the file, string and pattern > arguments, but the result of each expansion is constrained to be a > single word, similar to the effect of double quotes." I could have read that 1,000 times and not understood that it applied to my situation. > You're trying to match each against (in your case with MARK_DIRS set) > "2005-08-24/ 2005-08-26/ 2005-08-27/ 2005-08-28/ 2005-08-29/" > Try a different solution, e.g.: > > for i in *(^M) > do > > if [ -d "$i" ]; then > case $i in > 2[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]) echo "YES: $i";; > *) echo "no: $i" ;; > esac > > fi > > done Ah! That works! Thanks. I am using this, together with the previous script about getting the creation date, to easily sort folders with lots of stuff in them into folders with contents organized by creation date. Thanks! TjL