J'ai un script vérifiant si un fichier est à la minute.comparer des chaînes dans bash
updatedate=`ls -l file | sed -e 's/ */ /g' | cut -d' ' -f7` #cut the modification time
nowdate=`date +"%H:%M"`
echo "$updatedate $nowdate"
if [ "$updatedate"="$nowdate" ]
then
echo 'OK'
else
echo 'NOT OK'
fi
Mais quand je le lance, la comparaison est toujours vrai:
$ ./checkfile
10:04 10:07
OK
$ ./checkfile
10:07 10:07
OK
Pourquoi?
[est un raccourci pour tester, voir http://pubs.opengroup.org/onlinepubs/009695399/utilities/test.html (ce commentaire est pour l'OP);) –