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.
Asked
Active
Viewed 506 times
0
-
Did you try anything? – Valentino May 09 '19 at 21:14
-
There's lots of threads on this topic already, just google "bash spinning prompt" – Adam vonNieda May 09 '19 at 21:15
-
Like [Spinner Animation and echo command](https://stackoverflow.com/questions/47234947/spinner-animation-and-echo-command/47235185?r=SearchResults&s=1|32.8605#47235185) ? Adjust the text output as desired. – David C. Rankin May 09 '19 at 21:30
1 Answers
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