1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#! /bin/bash set -o errexit # the script ends if a command fails set -o pipefail # the script ends if a command fails in a pipe set -o nounset # the script ends if it uses an undeclared variable declare -a ARRAY; ARRAY=("cero" "uno" [3]="tres") ARRAY[2]="dos" LENGTH=${#ARRAY[*]} for (( i=0; i<LENGTH; i++ )); do echo $i=${ARRAY[i]} done |
Al ejecutar el SCRIPT nos arrojara el siguiente resultado :
1 2 3 4 |
0=cero 1=uno 2=dos 3=tres |