Quote:
Originally Posted by towardstheedge
The part I am having trouble with is generating a report on the status of the whole thing while it is still running.
|
It would have been more interesting if you would have listed the actual scripts you used...
Quote:
Originally Posted by towardstheedge
I want to be able to list the current bucket.* files that exist and the contents of them. They will each only contain a random number between 1 and 5.
|
If you assert a single bucket is passed along the line (only one "bucket" file exists in the directory) then you could:
Code:
BUCKETS=0; GALLONS=0
..
if [ -f ./bucket ]; then
((BUCKETS++))
CONTENT=$(cat ./bucket)
GALLONS=$[${GALLONS}+$CONTENT]
else
echo "Oi! Where's me bucket?"
fi
if there's multiple buckets and you have to "pass" them in numeric order (bucket.001, bucket.002)
Code:
incr() { ((BUCKETS++)); GALLONS=$[${GALLONS}+$1]; }
find . -type f -name bucket.\*|sort -n|while read BUCKET; do
CONTENT=$(cat ./bucket); incr $CONTENT
done
and somewhere at the end
Code:
echo "Passing ${BUCKETS} buckets containing ${GALLONS}"
*BTW unless it's a hard requirement
actual bucket files shouldn't be necessary: one script, or a script consisting of several
functions, could supply another script or function with bucket names and contents as arguments.