emanuele6 1666590115 learn The ${#var} parameter expansion expands to the character length of $var. If you need the byte length, instead of temporarily changing LC_CTYPE to "C", you can use bash's printf with %n (which behaves like the C equivalent) like so: printf -v _ %s%n "$str" byte_length . Note that, even though was added in bash2.05a and was mentioned in the changelog, %n is not documented. emanuele6 1666590969 forget emanuele6 1666590981 learn The ${#var} parameter expansion expands to the character length of $var. If you need the byte length, instead of temporarily changing LC_CTYPE to "C", you can use bash's printf with %n (which behaves like the C equivalent) like so: printf -v _ %s%n "$str" byte_length . Note that, even though it was added in bash2.05a, and was mentioned in the changelog, %n is not documented. emanuele6 1675264657 forget emanuele6 1675264680 learn The ${#var} parameter expansion expands to the character length of $var. If you need the byte length, instead of temporarily changing LC_CTYPE to "C", you can use bash's printf with %n (which behaves like the C equivalent) like so: printf -v _ %s%n "$str" byte_length .