unix

how to display a string character by character on the screeen?
a_puru_rAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
fflush
0
expert99121199Commented:
This little script will echo the letters in a word one at a time with a one second pause between each letter.  It is efficient because it is all in shell (except sleep, which can be removed).  It works by executing the program with the word (STRING) you wish to display provided on the command line.  As written the word must be all lower case with no spaces.  You should be able to figure out how to handle mixed case easily.  I hope this is what you were looking for.

expert99

#!/bin/sh
OLDIFS="$IFS"
STRING="$*"

while [ "$STRING" != "" ]
do
        for C in a b c d e f g h i j k l m n o p q r s t u v w x y z
        do
                IFS="$C"
                \s\e\t -- $STRING
                IFS="$OLDIFS"
                case "$STRING" in
                        "$C"?*)echo "$C\c"
                        sleep 1
                        case "$#" in
                                1)STRING="$1";;
                                2)STRING="$1$C$2";;
                                3)STRING="$1$C$2$C$3";;
                                4)STRING="$1$C$2$C$3$C$4";;
                        esac
                        ;;
                        "$C")echo "$C"
                        break 2;;
                esac
        done
done
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
As written the word must also have no repeated letters
0
expert99121199Commented:
ozo is correct!  Let me know if this is what you had in mind and I will enable it to handle Mississippi - or other words with repeating letters.  This design cannot be made to handle arbitrary strings - it is for words, spaces, numbers, etc.  Punctuation will also present a challenge.  Still, it may be what you are looking for.

expert99
0
ozoCommented:
perl -e '$|=1; $_=shift; for( /./g ){ print; sleep 1 }' 'Mississippi - or other words with repeating letters'
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.