Hi,
I need help on for loop need to add domain and IP
In domain list
1.com
2.com
3.com
In Ip list
1.1.0.1
1.2.0.1
1.3.0.1
1.com 1.1.0.1
2.com 1.2.0.1
3.com 1.3.0.1
I need to excute this command
/scripts/adddns --domain $I --ip $j
How i can write forloop for the above command.
You need a join, not a loop, a merge, so see man paste.
paste domain_list ip_list | while read i j
do
/scripts/adddns --domain $I --ip $j
done
See, not two loops, a merge.
This isn't mine, I got it from someone on the boards here awhile back. This should consolidate two files just like you're asking. Maybe put this in your script and use the passed variables?
awk 'BEGIN {i=0 ; while (getline < "File1") { l=$0 ; i++ } } ; { for (j=0 ; j<=i ; j++) { split(l[j],f) ; if (f[1] == $2) print $1,$2,f[2],$3,$4} }' File2
And I have never yet used the paste command! Real life does not do that!