Originally Posted By: Shonky

Code:
# Ensure the file is present. Works with both versions of the files.
if [ ! -f "$testFile" ]
then
  echo "Test file not found. Exiting."
  exit 1
fi
echo "Test file is present. Continuing program."


Note that the test above does not seem to be necessary given the code changes suggested further on, and in fact also serves to introduce a race condition into the script: the file could be removed or created elsewhere between the two tests. In this case, the race doesn't matter (really!), but it also demonstrates that the pre-test for existence above isn't as useful as one might think.

It's really a shame that "find" doesn't return a non-zero exit status for cases where nothing is found. Doing so could simplify scripts like this one, but would also break many others.

Cheers