times) in a Unix shell script? In bash, it's simple:
for ((i = 0; i < 25; i++ )) do ... done
You don't usually need this "C-style" loop in a shell script; shell loops (where you iterate over a set of strings) are often much more convenient. But when you do,
nothing else will work. This loop was from a script to test Google's public DNS server, where I needed to make a large, fixed number of queries against the server.
This trick, and many others, are in the Bash Cookbook
Learn more about this topic from bash Cookbook.
bash Cookbook teaches shell scripting the way Unix masters practice the craft. It presents a variety of recipes and tricks for all levels of shell programmers so that anyone can become a proficient user of the most common Unix shell -- the bash shell -- and cygwin or other popular Unix emulation packages. Packed full of useful scripts, along with examples that explain how to create better scripts, this new Cookbook gives professionals and power users everything they need to automate routine tasks and enable them to truly manage their systems -- rather than have their systems manage them.
and Learning the Bash Shell
Learn more about this topic from Learning the bash Shell, 3rd Edition.
This refreshed edition serves as the most valuable guide yet to the bash shell. It's full of practical examples of shell commands and programs guaranteed to make everyday use of Linux that much easier. Includes information on key bindings, command line editing and processing, integrated programming features, signal handling, and much more!

Help




