Essentials of Bash Scripting: Using Loops | Linux Today

Essentials of Bash Scripting: Using Loops

Written By
Web Webster
Web Webster
Oct 22, 2010

“An essential rule of system administration: If you need to do
something often, try to write a script to do it for you. If you
need to do something several times within a script, you’ll need to
be able to use loop statements to repeat something until done. With
GNU Bash, you’ll do this with for, while, and until statements.

“If you’ve done any programming, you’re probably familiar with
these statements already. If you’re like me, and were introduced to
bash scripting without benefit of a programming background, they
might not be quite so obvious. Let’s start by explaining the
differences between the statements, and then move on to
examples.

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


Complete Story

Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.