Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hostname range 1

Status
Not open for further replies.

msatishkumar143

Programmer
Joined
Sep 3, 2005
Messages
2
Location
US
Hi all,

I have a host range like this
a[1-3].it.{colo1,colo2,colo3}.yyy.com

are there any unix command which will get the output as .

a1.it.colo1.yyy.com
a2.it.colo1.yyy.com
a3.it.colo1.yyy.com
a1.it.colo2.yyy.com
a2.it.colo2.yyy.com
a3.it.colo2.yyy.com
...

and so on.

Thanks
Dinesh
 
If you have "[tt]seq[/tt]", you could do this...
Code:
seq 1 3 | while read INNER
do
    seq 1 3 | while read OUTER
    do
        print "a${OUTER}.it.colo${INNER}.yyy.com"
    done
done
 
If you don't have "[tt]seq[/tt]", this should work...
Code:
for INNER in 123
do
    for OUTER in 123
    do
        print "a${OUTER}.it.colo${INNER}.yyy.com"
    done
done

 
Oops, there should be spaces between the 1, 2, and 3.

 
In some shells you can just echo it in almost exactly the way you specified and it will be automatically expanded. I think this works in bash and ksh93, see this example in bash:

Code:
$ echo a{1..3}.it.{colo1,colo2,colo3}.yyy.com | xargs -n1
a1.it.colo1.yyy.com
a1.it.colo2.yyy.com
a1.it.colo3.yyy.com
a2.it.colo1.yyy.com
a2.it.colo2.yyy.com
a2.it.colo3.yyy.com
a3.it.colo1.yyy.com
a3.it.colo2.yyy.com
a3.it.colo3.yyy.com
$

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top