> ## Content Index
> Fetch the complete content index at: https://kudithipudi.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# HOW TO : for loop in bash
- URL: https://kudithipudi.org/how-to-for-loop-in-bash/
- Published: 2011-06-23T16:54:30.000Z
- Updated: 2011-06-23T16:54:30.000Z
- Description: 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...
- Author: admin
- Tags: Linux, Programming, Uncategorized, #wp, #wp-post, #Import 2026-08-23 02:32

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.