How to create the classic Linux progress bar using Bash Script. Those who are old enough may remember the old Linux kernel progress bar like this: “|”, “/”, “-“, “\” at the boot time. I quite like this style of the progress bar and decided to assemble a simple script for nostalgia purpose. Fortunately, I found a YouTube video by Kris Occhipinti that does a similar thing.
Below is the classic Linux progress bar code inspired by Kris Occhipinti’s video with some minor modifications:
progress() {
progressArr=( '|' '/' '-' '\' )
while [ 1 ]
do
for i in "${progressArr[@]}"
do
echo -ne "\r$i"
sleep 0.2
done
done
}
progress
This code can be combined with cp
command to add progress capability to it with some hack. That’s another post for another day.