Hi,
can you please help me with one question?
I need to create a file if it does not exist.
Something about:
while [[ -f "$file" ]]; do sleep 1; done
touch $file || echo "can not create $file"
But there is a little possibility that such file is created in the time gap between while and touch.
And to my regret I faced it.
touch does not return bad code if the file exists.
Does any way exist to handle it?
Thank you in advance.
Anta
can you please help me with one question?
I need to create a file if it does not exist.
Something about:
while [[ -f "$file" ]]; do sleep 1; done
touch $file || echo "can not create $file"
But there is a little possibility that such file is created in the time gap between while and touch.
And to my regret I faced it.
touch does not return bad code if the file exists.
Does any way exist to handle it?
Thank you in advance.
Anta