Saturday, April 16, 2011

how to find length of a variable in BASH?

lets define a variable first,
# TEST=1234567890
to find the length of variable TEST,
# echo ${#TEST}
10
its possible to assign the length to a new variable, say LENGTH
# LENGTH=${#TEST}
# echo $LENGTH
10
now try to find the length of the following variable,
# TEST="my length is"
Technorati Tags: ,