while : ; do
[[ -f "/path/to/file" ]] && break
echo "Pausing until file exists."
Without using something like
inotify, this is about the limit of what you're going to be able to do.
while loop above just uses
: as its conditional which pretty much just means "do it until we kill it."
The important line is the
[[ test. The test conditional here does not use the
if statement. This is because
[[ is an actual command and NOT part of the
if statement. This executes
[[ -f "/path/to/file" ]] and the
&& checks the exit status of the
[[ command and executes the following statement if that exit status is
0 (success). The following statement here is
break which will close out the current loop that your script is in.
bash it is highly recommended that you use
[[ instead of
[. It has all of the capabilities of
[ but is far more powerful and simple to use.