I ran into a similar problem and it brought me here, so I just wanted to leave my solution for those who are experiencing the same.
I found that if I ran cat /tmp/list.txt , the file would be empty, although I was sure that the contents were immediately placed in the file. It turns out if I put sleep 1; just before cat /tmp/list.txt , it worked as expected. There should have been a delay between the time the file was created and the time it was written, or something in that direction.
My last code is:
while [ ! -f /tmp/list.txt ]; do sleep 1; done; sleep 1; cat /tmp/list.txt;
Hope this helps save someone a disappointing half hour!
Zane Hooper Sep 16 '14 at 17:18 2014-09-16 17:18
source share