How to make a progress bar for bash command
run_command_progress()
{
local n=0
local steps=$2
local progress_bar=""
local counter=0
local files=0
ECHO "run_command_progress: '$1'"
[ -z "$steps" ] && { steps=1; }
[ -n "$3" ] && [ -d "$3" ] && { steps=`find $3 | wc -l`; steps=`expr $steps / 50`; }
eval $1 | while read line
do
#((n++))
#((files++))
((++n))
((++files))
if [ $n -ge $steps ] ;
then
#((counter++))
((++counter))
if [ $counter -le 50 ] ;
then
progress_bar="$progress_bar#";
printf " --------------------------------------------------|\r[%03d]$progress_bar\r" $steps
else
printf "[%03d#$progress_bar|\r" `expr $files / 50`
fi
n=0
fi
done
echo ""
}