lacrosse1991 lacrosse1991 - 5 months ago 64
Linux Question

how can I count the amount of characters in a bash variable

how can I count all characters in a bash variable? so for instance if I had


the result would be


I've searched around on google, but so far have only been able to find out how to count specific characters (say the letter "a" for instance)

thanks for your help!

Answer Source

Using the ${#VAR} syntax will calculate the number of characters in a variable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download