bash: array - Determine the length of an array and the length of an array element.



  • Take into account the main readme for this section. README first.

    An array called planet.

    $ declare -a planet=(earth wind fire)
    

    Determine length of an array name.

    $ echo "${#planet[@]}"
    3
    

    Determine length of an array element. Here element 1 and 0

    $ echo "${#planet[1]}"
    4
    $ echo "${#planet[0]}"
    5
    

Log in to reply
 

© Lightnetics 2024