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 a Money-Back Guarantee

    headlines below...

    Basic awk lesson

    Build Android apps with XML and JavaScript Object Notation

    Create mobile Web apps with HTML5

    Migrate Linux apps to the Amazon cloud

    6 tips for XML flavor of HTML5

    Free Linux Game Engines

     

    Firefox sidebar

    Site map

    Site info

    News feed

    Features

    Login
    (to post)

    Search

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