0

i am trying to run a code in Linux which might take around 5 minutes, while the code is executing i need to display a loading status in command window. help me in writing this.

1 Answers1

0

I'd say you should add some sort of loading animation which makes it more clear 'stuff' is happening, or at least should be. There are ofcourse many ways to do this, but this is most aesthetically pleasing while being simple at the same time to me.

printf "Loading, please wait a moment.\n\n" 

states="/-\|"

while [ -z ${VARIABLENAME+x} ] do
  for (( i=0; i<${#states}; i++ )); do
    sleep 0.75
    echo -en "${states:$i:1}" "\r"
  done
done

You should run that, and set a VARIABLENAME to stop the loop and use clear to remove the last loop that executed and the printf.

TKTurbo
  • 92
  • 1
  • 11