bash: Test if a file is older than another file.
-
Take into account the main readme for this section. README first.
Using the test option
-ot
older than.FILE1=/tmp/myfile1 FILE2=/tmp/myfile2 if [[ "$FILE1" -ot "$FILE2" ]];then echo "Keeping $FILE1 because it is older than $FILE2 " fi
The script execution output of the script is:
$ ./test.sh Keeping /tmp/myfile1 because it is older than /tmp/myfile2
© Lightnetics 2024