simple progress bar in bash script

Example of a simple progress bar in bash script:

#!/bin/bash

PAGELOADS=30000;
PBAR_LEN=30;
PBAR_STEP=$[$PAGELOADS/$PBAR_LEN]

for i in `seq 1 $PAGELOADS`
do
fname="`date +%F-%T`.html"
time wget http://site/page -O $fname >> .log 2>>.log
cat $fname | grep NATURE > /dev/null && rm $fname
sleep 1

#simple progress bar for fun:
clear;
PBAR=$[$i/$PBAR_STEP]
echo -n "[";
for j in `seq 1 $PBAR_LEN`
do
if [ $j -gt $PBAR ]; then
echo -n ".";
else
echo -n "*";
fi
done
echo "] [$i/$PAGELOADS]";

done

Leave a Reply

Your email address will not be published. Required fields are marked *