I am writing a little script to process folders. The runtime time is quite long so I would like to add a progress bar.
Here is the iteration :
for file in */
do
#processing here, dummy code
sleep 1
done
Having a counter and knowing the number of folders would be a solution. But I am looking for a more generic and a shorter solution...
I hope someone would have an idea. Thank you for your interest,
Julien
Edit :
I get this solution which do what I want, and is really graphical :
#!/bin/bash
n_item=$(find /* -maxdepth 0 | wc -l)
i=0
for file in /*
do
sleep 1 #process file
i=$((i+1))
echo $((100 * i / n_item)) | dialog --gauge "Processing $n_item folders, the current is $file..." 10 70 0
done
However, I will keep fedorqui 's solution which doesn't take all the screen.
Thank you very much for your time