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:8208 | -Ray, October 27, 2010
More Programming articles...

Colorful Abstract Art

coding headlines

Tutorial: Install SVN, Configure multi-protocol access (Ubuntu 11.10)

perl1line.txt: A handy Perl script collection

String matching in regular expressions

Create native looking Firefox web apps

Tutorial: Android app build environment with Eclipse, PhoneGap (Ubuntu 11.04)

Command substitution in Bash scripting

 

Firefox sidebar

Site map

Site info

News feed

Features

Login
(to post)

Search

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