I find shell scripts arcane and difficult to understand, especially the one liners! I would use a delightful python script, for example:
import os,sys,glob,time
if len(sys.argv) != 3:
print 'Usage %s: wildcard time_to_wait'
raise SystemExit
stub = sys.argv[1]
wait = sys.argv[2]
try:
wait = int(wait)
except ValueError:
print 'Invalid wait time, use an integer number of seconds'
raise SystemExit
done = False
while not done:
now = time.time()
modify_times = [(now-os.stat(filename).st_mtime) for filename in glob.glob(stub)]
modify_times.sort() #ascending sort, so the first one is the most recent
if modify_times[0] > wait:
done = True
else:
#Don't kill the cpu by sitting in this loop forever, the absolute quickest that we could
#exit this loop is wait-modify_times[0], so sleep for that long
time.sleep(wait-modify_times[0])
It waits until all of the files matched by a wildcard (e.g file*) are older than a given number of seconds. You need to escape the wildcard so it doesn't get expanded by the os though, ./wait.py "file*" 300 for example