All pastes #335498 Raw Edit

Untitled

public shellscript v1 · immutable
·published 2007-02-01 11:03 UTC
rendered paste body
#!/bin/bashindex=0set -x# The new_hosts.txt file has lines in the format:# hostname x.x.x.x y.y.y.y # being both ips# The purpose is to read the file and store the values in an array# for several different purposes, but it's not workingcat new_hosts.txt |cut -d\  -f1- | while read _host _ipold _ipnew; do((index++))echo "c=$index, ip_new=$_ipnew, server=$_host, ip old=$_ipold"host[${index}]=$_hostipnew[$index]=$_ipnewipold[$index]=$_ipolddone# Why $index=0?echo "RESUMEN FINAL ($index)"for ((i=1;$i<40;i++)); do  echo "servidor $i: ${host[$i]}, ip antigua: ${ipold[$i]}, ip nueva: ${ipnew[$i]}"done