Monday, December 18, 2023

How to Display a Spinner for Long Running Tasks in Bash

#! /bin/bash
sleep 5 & pid=$!
 
i=1
sp="\|/-"
while ps -p $pid > /dev/null
do
    printf "\b%c" "${sp:i++%4:1}"
    sleep 0.1
done
printf "\nDone!\n"

https://www.baeldung.com/linux/bash-show-spinner-long-tasks

0 Comments:

Post a Comment

<< Home