Loops in the UNIX Shell
(Page 1 of 4 )
History is repeating itself. How many times have you heard this? Unless you live isolated inside of a cave on a mountain top, with no information source around, you've probably heard this countless times. But never mind history; you've probably found that it would be convenient to make your computer repeat the same tasks over and over. Within a programming language, we refer to this structure as a loop.
This article is part of the series I write related to shell programming. From this, you can already conclude that today if you stick with me until the end you will learn all about loops in the UNIX shell programming.
As you may have already figured out, I will not start from the very beginning of this guide. I already covered a couple of interesting aspects of UNIX and shell programming in the earlier articles.
If you missed any one of them, you should suspend reading this article for now and read them first. It is almost pointless to start from the middle of a language. First, you need to know the basics.
For this article, you will need the basic concept of how a command works. Notions such as the echo command, the use of a text editor inside a terminal and how to work with a terminal are prerequisites if you plan to understand this article.
In my first article about UNIX shell control mechanisms, I explained that you need two basic structures for a programming language: the decision making and the loop. In the previous two articles, I covered the decision making well enough.
So the time has arrived for me to present the loop to you. There are three types of loops in the shell programming: the "for," the "while" and the "until."
Next: The loops >>
More Miscellaneous Articles
More By Gabor Bernat