The built-in test and [ utilities have the -nt ("newer than") and -ot ("older than") tests in most shells, even when the shell is running in "POSIX mode" (also true for the external utilities of the same names on the systems that I have access to). These tests are for comparing modification timestamps on two files. Their documented semantics are slightly varying across implementations (with regards to what happens if one or the other file exists on not), but they are not included in the POSIX spec. for the test utility.
They were not carried forward into the
testutility when the conditional command was removed from the [KornShell] shell because they have not been included in thetestutility built into historical implementations of theshutility.
Assuming I'd like to compare the modification timestamp between files in a /bin/sh shell script and then take action depending on whether one file is newer than the other, as in
if [ "$sigfile" -nt "$timestamp" ] || [ "$sigfile.tmp" -nt "$timestamp" ] then return fi ... what other utility could I use, apart from make (which would make the rest of the script unwieldy to say the least)? Or should I just assume that nobody is ever going to run the script on a "historical implementation of sh", or resign to writing for a specific shell like bash?
-ntfeature oftestin a way that is expected since approx. 1995. You should use thefindbasd expression even withbashif you like correct behavior.