I would like to ask if there is a way to count the number of elements in an array in ksh.
2 Answers
To count the number of elements use
${#array[@]}.
In order to get the length of a particular element use (I'm getting the length of the 3rd element)
echo ${#array[2]}.
According to the ksh man page:
${#parameter } If parameter is * or @, the number of positional parameters is substituted. Otherwise, the length of the value of the parameter is substituted.