HOW TO : for loop in bash

Quick post for my own reference down the road. the “for” loop comes in very handy, when you want to perform the same task on multiple items in a bash shell.

For example, I wanted to query the DNS results of a couple of sub domains (,,, I can do it the normal way (that 99% of us do 🙂 )

[code] dig


dig [/code]

Or, I can use the for loop function and do this

[code] for i in {blog,pr,tracker}; do echo "$i" ; dig +short "$i"; done [/code]

Got to love technology :).. Makes you lazy!!..err I meant to say productive.

Thx to Cliff for the inspiration.