creating rotating circle using characters |, /, \,- in shell script

shell

Solution

The accepted solution is overly complicated. You can just do:

while sleep 1; do 
  i=$((++i%4 + 2)); 
  printf '\b|/-\' | cut -b 1,$i | tr -d '\n';
done

(Note that subsecond sleeping is not portable, and neither is seq.)

Problem

I want to write a shell script which does installation related task. I want to show some icon like rotating circle by printing characters |, /, \, -. Once the installation completes this circle will disappear. Any help on this would be appreciated.

Original source