mardi 1 mai 2018

Bash if-then statement fails

I am trying to make bash delete unnecessary files depending on the days of the month in the following bash code:

if [${month} -eq apr] -o [${month} -eq jun] -o [${month} -eq sep] -o [${month} -eq nov]; then
    rm *31.nc
elif [${month} -eq feb]; then
    rm *29.nc
else
    echo "month has 31 days"
fi

Unfortunately I get the following error:

line 46: [jan: command not found

I would love to learn what I did wrong here.

Linda

Aucun commentaire:

Enregistrer un commentaire