Avatar of sytech1
sytech1
 asked on

Unix script

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
Unix OS

Avatar of undefined
Last Comment
sytech1

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
nixfreak

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
nixfreak

You can change the first line of the script to:
#! /bin/sh -x

to better understand the script operation
sytech1

ASKER
Thanks nixfreak ,
your comments were very helpful
Your help has saved me hundreds of hours of internet surfing.
fblack61