Tille - I can see you, read those man pages!   Tille's Site

Echo and read

This is my daughter's first example:

# Scriptname: halloclo.sh

echo "(Computer) Hello, what is your name?"
read name
echo -n "(Computer) How old are you, $name? "
read age
reply="$[$age +1]"
echo "(Computer) Then you're going to be $reply soon!"
echo "(Computer) Where do you live, $name?"
read city
echo "(Computer) $city is a nice place to live!"
echo "(Computer) What is your favorite television program, $name?"
read program
echo "(Computer) Oh yes, $program is what I like to watch too!"
echo "(Computer) It's very disappointing when my boss want to watch the news, just when $program is on."

# So as the program does not quit immediately upon execution, when opened in 
# a graphical file manager.
sleep 30

exit 0

Of course, for explaining to a seven year old you start with a small script that just says "hello", then you start with read and variables, and have the child(ren) add stuff that they make up themselves. For children, use gedit and nautilus or some such combination for editing the script and executing it. Have fun ;-)

© 1995-2010 Machtelt Garrels - tille - Powered by vIm - Best viewed with your eyes - Validated by W3C - Last update 20100511