Bonjour à tous, après avoir lu divers informations sur les scripts bash j'essaye de comparer des strings et là, franchement, je sèche...
Y aurait-il quelqu'un pour m'expliquer ce résultat??
Merci beaucoup!
Le code :
datauj=$(date +%m/%d/%Y);
var="01/26/2011";
echo $datauj $var "Are the two dates"
if [[ $datauj!=="$var" ]]
then
echo "Not equal";
elif [[ "$datauj"=="$var" ]]
then
echo "Equal"
fi
var="01/27/2011";
echo $datauj $var "Are the two dates"
if [[ $datauj!=="$var" ]]
then
echo "Not equal";
elif [[ "$datauj"=="$var" ]]
then
echo "Equal"
fi
Résultat:
01/26/2011 01/26/2011 Are the two dates
Not equal
01/26/2011 01/27/2011 Are the two dates
Not equal
Partager