Creating a Bash Spinner | Linux Journal 1of2

PHOTO EMBED

Sat Jul 30 2022 10:01:04 GMT+0000 (Coordinated Universal Time)

Saved by @gistbucket

#!/bin/bash

logfile=/tmp/mylog

echo >$logfile
trap "rm -f $logfile" EXIT

# Output message to log file.
function log_msg()
{
    echo "$*" >>$logfile
}


# Start spinner
sh spinner.sh &

# Perform really long task.
i=0
log_msg "Starting a really long job"
while [[ $i -lt 100 ]]
do
    sleep 1
    let i+=5
    log_msg "$i% complete"
done

sleep 1
echo
content_copyCOPY

https://www.linuxjournal.com/content/creating-bash-spinner