How do I count the length of a variable in a bash shell script?



  • Usage is ${#name}

    MyLocation=Utah
    echo ${#MyLocation}
    

    The variable MyLocation has value Utah and it is 4 characters in length.

    $ ./associative_array.sh
    4
    

Log in to reply
 

© Lightnetics 2024