Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: trying to match yyyy-mm-dd what am I missing?

On Sep 3, 2005, at 9:04 AM, Geoff Wing wrote:
Timothy Luoma <lists@xxxxxxxxxxxx> typed:
: I am trying to match all folders in the CWD which are in the format
:          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
 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)

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" ;;



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.


Messages sorted by: Reverse Date, Date, Thread, Author