1、${#str}
str="hello" echo ${#str}
2、awk
str="hello" echo $str | awk '{ print length($0) }' or echo $str | awk -F "" '{ print NF }'
3、wc
str="hello" echo $str | wc -L or echo -n $str | wc -c
4、expr
str="hello" expr length $str
1、${#str}
str="hello" echo ${#str}
2、awk
str="hello" echo $str | awk '{ print length($0) }' or echo $str | awk -F "" '{ print NF }'
3、wc
str="hello" echo $str | wc -L or echo -n $str | wc -c
4、expr
str="hello" expr length $str