hi,
I would like to calculate number of character for a number,
for exemple : 1200 --> there are 4 characters , 120001 -> 5 characters
hi,
I would like to calculate number of character for a number,
for exemple : 1200 --> there are 4 characters , 120001 -> 5 characters
a=1200
echo ${#a}
And number of characters in 120001 is 6 and not 5.
$ echo "120001" | awk '{print length($1)}'
6
Its always better to use shell builtin's as VINO suggested ${#var}
Yes, I agree, and vino's command is the best.