Friday, August 8, 2014

Move text round and round on same line in UNIX

## Move Text ROUND and ROUND on same line in UNIX
## Script is self explaining. Use the comment box for any doubts


move_text()
{
#USAGE: move_text "TEXT TO ROTATE" "NUMBER_OF_TIMES"
 typeset -i i k m count;
 m=0;
 count=${2:-2}
 while [ "$m" -lt $count ]
 do
  i=0;
  k=1;
  while [ "$i" -lt 10 ]
  do
   j=0;
   while [ "$j" -lt "$k" ]
   do
     echo "\t\c"
     j=$((j+1))
   done
   echo "$1\c"
   sleep 1
   tput cub 100
   i=$((i+1));
   k=$((k+1))
  done

  m=$((m+1))
  tput el1
  tput el
 done
echo
}

move_text "...I can move 5 times...." 5

move_text "...I can move 2 times...."    #default parameter will be taken as 2

No comments:

Post a Comment