From Table 7-1 of Bash Guide for Beginners, we can say that [ FILE1 -ot FILE2 ]
will yield True if FILE1
is older than FILE2
, or
Try this experiment (in a script):
In the case I tested: when file1 does not exist and when file2 does exist:
#!/bin/sh
[ file1 -ot file2 ] && echo "file1 older" || echo "file2 older"
yields file2 older
#!/bin/bash
[ file1 -ot file2 ] && echo "file1 older" || echo "file2 older"
yields file1 older
By default make will use #!/bin/sh as the shell, you can change this by: SHELL = /bin/bash
in your makefile
I am not sure why this is different - its just a different implementation between sh and bash...