look over the code written by your classmates. How well would you be able to troubleshoot, modify , or use their scripts? What does this tell you about your own scripts?
$* and $#
These two variables help you get info about the args passed to the script.
learn about sourcing files
. filename
Note what happens to your vars...
other ways to get vars into shells
var1="value1" var2="value2" script
``
learn shell flow control
testing
- exit codes
test condition
[ condition ] (spaces are critical, as [ is an alias for test)
- see text for test switches
if then - elif - else - fi
if [ condition1 ]
then
do something
elif [ condition2 ]
then
do something
else
do something
fi
while
while [ condition2 ]
do
do something
done
while 1, while :
for
for var in list
do
do something with $var
done
until
until [ condition ]
do
do something
done
switch/case
case value in
pattern1|pattern1a) command;command;;
pattern2) command;command;;
pattern3) command;command;;
pattern4) command;command;;
*) command;command;;
esac
loop shortcuts
break bust out of current loop, perhaps more than one
continue force next iteration of current loop
exit exit current shell, perhaps with errorlevel
Homework
- command substitution
- subshells
- command stacking
- intermediate redirection
- debugging
http://www.mousetrap.net/syllabus/shell/day2.html
$Id: day2.orb,v 1.13 2002/11/25 13:21:31 mouse Exp $