vendredi 17 janvier 2020

Correct way to filter results with if statement in bash loop

I'm trying to work out a loop that will let me ignore some matches. So far I have:

for d in /home/chambres/web/x.org/public_html/2018/js/lib/*.js ;  do
    if [[ $d =~ /*.min.js/ ]];
    then
        echo "ignore $d"
    else
        filename="${d##*/}"
        echo "$d"
        #echo "$filename"
    fi

done

However when I run it, they still seem to get included. What am I doing wrong?

/home/chambres/web/x.org/public_html/2018/js/lib/underscore.js.min.js
/home/chambres/web/x.org/public_html/2018/js/lib/tiny-slider.js
/home/chambres/web/x.org/public_html/2018/js/lib/tiny-slider.js.min.js
/home/chambres/web/x.org/public_html/2018/js/lib/underscore.js

BTW I'm a bit of a newbie with bash, so please be kind ;)

Aucun commentaire:

Enregistrer un commentaire