#!/bin/bash ### rundots() { ( trap 'exit 0' SIGUSR1; while : ; do echo -ne '.' >&2; sleep 0.2; done) & dotpid=$!; } ### stopdots() { kill -USR1 $dotpid; wait $dotpid; trap EXIT; } ### startdots() { echo -e "\nExecuting function >>>> $(tr [a-z] [A-Z] <<< "${FUNCNAME[ 1 ]}") <<<<<" echo -ne "---->>Script executing, please wait" rundots; trap "stopdots" EXIT; return 0; sleep 0.3} ### main1() { startdots echo -e "display space usage" > /tmp/shell_script.log sleep 4 du -sh * >> /tmp/shell_script.log stopdots } main2() { startdots echo -e "list files," >> /tmp/shell_script.log sleep 4 ls -lsrt >> /tmp/shell_script.log stopdots echo -e "\n\n*********** END OF THE BASH SCRIPT ************" } ### call functions main1 main2