lacrosse1991 lacrosse1991 - 8 months ago 87
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

"stackoverflow"


the result would be

"13"


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.

http://linux.about.com/od/bgb_guide/a/gdebgb78t01.htm

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