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 (blog.gogoair.com, pr.gogoair.com, tracker.gogoair.com), I can do it the normal way (that 99% of us do
)
dig blog.gogoair.com dig pr.gogoair.com dig tracker.gogoair.com
Or, I can use the for loop function and do this
for i in {blog,pr,tracker}.gogoair.com; do echo "$i" ; dig +short "$i"; done
Got to love technology
.. Makes you lazy!!..err I meant to say productive.
Thx to Cliff for the inspiration.