Bash can transform variables for you as it expands them, with no extra programs like sed or awk. These are called Shell Parameter Expansions, and they are written as ${variable...}.
| |
If you want the length of a value, see the quick tip on counting characters in a string.