I need not just an answer for the following situation, but an explanation please. There are 2 files - NEW and OLD:
touch NEW ;
touch -t $(date -d '3 week ago' +%Y%m%d%H%M) OLD
Now i'm making the script to output different messages according to the results of comparison of a NEW file to the old one:
#!/bin/bash
if [[ "$NEW" -ot "$OLD" ]]
then echo "file is old"
elif [[ "$NEW" -nt "$OLD" ]]
then echo "file is new"
fi
But no matter which condition is correct, "file is old" will always be printed.
The same situation with IF ELSE FI statement.
Where am i wrong?
Aucun commentaire:
Enregistrer un commentaire