in my question i learn to use loops and with you help I final a installation script for multible instance of a software. thank you very much :)
now I try to automatic setup the configuration files by using sed. For this i need multible variables in a loop.
I read from the system the IP-Adresses and the hostnames for the IP's (PTR)
IPADDR=`ifconfig | awk '{print $2}' | egrep -o '([0-9]+\.){3}[0-9]+'|grep -v 127.0.0.1`
for ipaddr in ${IPADDR[@]}; do echo $ipaddr; done
for iphost in ${IPADDR[@]}; do host $iphost |grep pointer | awk '{print $NF}' RS='.\n'; done
my Script know, there ar 3 IP's, know the IP-Addresses and the Hostnames.
the numbers of IP (3) are now my 001 002 003. this running well.
if I like to edit the config files with sed, I need the 3 variable to do this.
command anyname-001 -some -parameter in my case is a copy to a path. my path is now
/etc/anyname-001, /etc/anyname-003 and /etc/anyname-003
by using sed I need also the 3 IP-Addresses and the 3 hostnames.
sed -i 's/IPADDR/'${ipaddr}'/g' /etc/anyname-${number}/config.cfg
sed -i 's/HOSTNAME/'${hostname}'/g' /etc/anyname-${number}/config.cfg
how can I bring my loop to this with all variables on same time. T try many things. I found nested loops but it not work
001 >> IP:a.a.a.a >> hostname aaa.aaa.aa
002 >> IP:b.b.b.b >> hostname bbb.bbb.bb
003 >> IP:c.c.c.c >> hostname ccc.ccc.cc
Thank you