UNIX – Script lee archivo y guarda los elementos en un Array, luego los muestra.-

#!/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
Esta entrada fue publicada en Unix - Linux. Guarda el enlace permanente.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *