while : ; do
[[ -f "/path/to/file" ]] && break
echo "Pausing until file exists."
sleep 1
done
Without using something like inotify, this is about the limit of what you're going to be able to do.
The 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.
Note: 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.
Ctrl-Kso you don't have to escape anything! – slhck♦ Oct 21 '12 at 20:49$trace,$hist_lenand$page_size? What is the error you're getting? Why do you need to escape the/? – Ansgar Wiechers Oct 21 '12 at 20:58waitis probably not the command you are looking for.waitwill pause a script until all child processes are done, at which point it will continue. – UtahJarhead Oct 22 '12 at 13:52