How do I find the length of a string in Linux?

How do I find the length of a string in Linux?
Answer
Any of the following syntaxes can be followed to count the length of string.
  1. ${#strvar} expr length $strvar. expr “${strvar}”:’. …
  2. $ string=”Hypertext Markup Language” $ len=`expr length “$string”` $ echo “The length of string is $len”
  3. #!/bin/bash. echo “Enter a string:” read strval. …
  4. #!/bin/bash. strval=$1.
 

Tìm kiếm

Back
Top