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

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



I am trying to match all folders in the CWD which are in the format YYYY-MM-DD.

Actually I'm just trying to match the ones from 2000 so I am using

2[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]

as my regex.

This is my script:

for i in *
do

if [ -d "$i" ]
    then
        if [ "$i" = 2[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] ]
    then
        echo "YES: $i"
    else
        echo "no: $i"
    fi
fi

done

Here are the results:

YES: 2005-08-24/
no: 2005-08-26/
no: 2005-08-27/
no: 2005-08-28/
no: 2005-08-29/
no: access.log/


So it is only matching the first one, and I can't figure out why.

TjL

ps - actually I eventually want to match any file/folder that is NOT (a directory AND in yyyy-mm-dd format)





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