|
Scripting: Looping in Bash |
 vote
 |
|
Looping constructs for bash scripts...
The for loop is used to iterate through an action until done. Let's say you have a directory full of images that you want to convert from one format to another. You could use a for loop and ImageMagick's convert (or another program) to convert JPEG images into PNG format, for instance. Or create a script to take a directory full of MP3s or WAV files and convert to Ogg Vorbis.
The while loop is used to perform an action while a condition is true, and until does the opposite — it performs an action until a condition is true. So you might run a counter, for example, up to 10 and perform an action until the counter hits 10. We'll look at this more closely in the examples.
| | |
| |
|
| | read more | mail this link | score:7827 | -Ray, October 27, 2010 |
| |
|
More Programming articles... |
|
|