Scripts, like any other programming language, may contain subroutines. A common way to use a subroutine is:
#!/bin/sh
usage()
{
echo " "
echo "You have not used this program correctly."
echo "Use as: prog_name par1 par2 ..."
echo " "
exit 1
}
one_par()
{
echo
echo There was only one parameter in the command line.
echo
return 1
}
larger()
{
echo
echo There were many parameters.
echo
return 1
}
case $# in
0) usage;;
1) one_par ;;
*) larger ;;
esac
exit 0
Note that routines must be defined prior to being used and that all variables
are global.