1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#!/bin/ksh HOSTFILE=myhosts i=0 for host in $(cat $HOSTFILE) do HOST[${i}]=$host (( i=i+1 )) done hostcount=${#HOST[*]} print "\n$hostcount hostnames have been stored in the array." print "\nThe hostnames stored in the array are:\n" j=0 while [ $j -lt $hostcount ] do print ${HOST[$j]} (( j=j+1 )) done |