I have a program which sometimes writes empty outputs
$ cat ex.py
import numpy as np
outf = open('out.dat', 'w')
if np.random.random() < 0.2: print >> outf, 'something'
I want to run ex.py
until there is content in out.dat
. Here is my best attempt so far. This is not working for me. What am I doing wrong?
$ cat ex.sh
while [ -s out.dat ]
do
python ex.py
done
~/Documents/bigyawarticle $ . ex.sh
~/Documents/bigyawarticle $ tail out.dat
Edit Thanks I got the spacing issue.