Answer the question
In order to leave comments, you need to log in
How to get the number of characters in a unicode string in bash?
The string contains Cyrillic and English letters. How to get number of letters in bash script?
For example:
Need to get . Tried:TEST="йцукенasdf"
10
CHRLEN=$(wc -m <<< $TEST)
printf "%s has %d characters\n" "$TEST" "$CHRLEN"
CHRLEN=${#TEST}
Answer the question
In order to leave comments, you need to log in
For some reason it shows 11, 1 more than the truth.
<<<
adds a newline character to the end.
CHRLEN=$(echo -n $TEST | wc -m)
printf "%s has %d characters\n" "$TEST" "$CHRLEN"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question