|
step 1: vi myshellscript1
step 2:
echo “ Please enter
your name : “
read name
echo “ Hello $name
“
echo “ “
echo “ Enter your two
favorite cities : “
read city1 city2
echo “ “
echo “ $name , you
entered $city1 and $city2 …”
echo “ “
echo “ We hope you
will time to visit your favorite cities soon . “
==================================================
step 3:
chmod 755 my shellscript1
step 4:
./myshellscript1
--------------------------------------
Another shell script exercise.
UNIX shell script
exercise
Below is a shell script that combines system variables ($LOGNAME),
system command (uname –a), and UNIX fundamental command (ls).
The sleep is the shell command. It pauses the output for
the specified number of seconds.
#!/bin/sh tell UNIX to go directly to the Bourne
shell.
# by itself is used to comment out the line.
Be careful with the ` symbol; it is known as the grave
accent and it is located above the tab key. It tells UNIX to execute the command
within the enclosing grave symbols (e.g. ` `)
#!/bin/sh
# written by a student
echo "Hello $LOGNAME, it is nice talking to you."
echo "Your present working directory is `pwd`"
echo "You are working on a machine called `uname -a`"
sleep 5
echo "Here is the listing of your files"
ls
echo "Bye for
now $LOGNAME. The time is `date+%T`!"
|