- Linux Shell Scripting Cookbook(Third Edition)
- Clif Flynt Sarath Lakshman Shantanu Tushar
- 37字
- 2021-07-09 19:46:00
Finding the length of a string
Get the length of a variable's value with the following command:
length=${#var}
Consider this example:
$ var=12345678901234567890$ echo ${#var} 20
The length parameter is the number of characters in the string.