Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Bash script using input to iterate through array

echo -e "Enter value between 0-5: c"
read -r readusr

month=("JAN" "FEB" "MAR" "APR" "MAY" "JUN")

echo -e "User chosen month is: c"
echo ${month[$readusr]}

echo -e "All months are: c"
echo ${month[@]}

echo -e "Numbers of months are: c"
echo ${#month[@]}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Bash #script #input #iterate #array
ADD COMMENT
Topic
Name
7+4 =