I've written a short bash script to monitor the line count growth (wc -l) in a file which is receiving results from a loop.
Thus:
printf "Name of file to monitor\n"
read file
printf "How long to monitor file growth in minutes\n"
read time
printf "Interval between loops\n"
read s
a=$((time * 60)) # works out overall time in seconds
b=$((a / s)) # no of loops
for i in $( eval echo {0..$b} )
do
printf "Loop number: %-10.2d Interval: %-10.2d Line Count: %-10.2d.\n" $i $s $'wc -l $file'
sleep $s
done
printf "finished\n"
I'm having problems with the last argument of the printf line. I'm not sure how to correctly state the wc function within the printf function.
wcto output the number use$(wc -l $file). And for good programming practices, you should use quotes (either single or double) around variables. Take a look at this post.