troubleshooting Question

Unix script

Avatar of sytech1
sytech1 asked on
Unix OS
3 Comments1 Solution1489 ViewsLast Modified:
Hi expert i am new in unix and i have been learning a lot through this site.
i found this script below on one of the post but i was really interested to see if someone maybe  expert99 Can  place some comments into the script to describe what it is doing from each line
Thanks

expert99:
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
ASKER CERTIFIED SOLUTION
nixfreak

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros