Bash has while and for loops, perhaps more but those are the only two I can think of off the top of my head. You can read more about them in the
Advanced Bash-Scripting Guide.
Also, bash supports sub-routines. Here's an example of a very simple one
Code:
usage()
{
echo "Usage: $0 [directory]"
exit 1;
}
which can be called like so
Code:
test -d "$1" || usage