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-K
so you don't have to escape anything!$trace
,$hist_len
and$page_size
? What is the error you're getting? Why do you need to escape the/
?wait
is probably not the command you are looking for.wait
will pause a script until all child processes are done, at which point it will continue.