4

I would like to ask if there is a way to count the number of elements in an array in ksh.

5

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]}.

| improve this answer | |
3

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.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.