Librenix  
(Show all Scripting articles . . .
)  
Headlines | Linux | Apps | Coding | BSD | Admin | News
Information for Linux System Administration 

Scripting: Looping in Bash

Up
vote
Down

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...

Buy Art Online with Satisfaction Guaranteed

coding headlines

No Starch Press has published my Perl One-Liners book!

OpenShift Online: a non-developer guide

Detailed Error Handling In Bash

Tutorial: Create an NFS-like Storage Server with GlusterFS on Ubuntu 12.10

Develop your own Raspberry Pi OS

 

Firefox sidebar

Site map

Site info

News feed

Features

Login
(to post)

Search

 
Articles are owned by their authors.   © 2000-2012 Ray Yeargin