Shell script to find string length

SCRIPT:
#!/bin/bash
echo -n "enter the string : "
read str
length=`expr $str|wc -c`
length=`expr $length - 1`
echo "the length of the entered string $str is $length"

OUTPUT:
sujin@sujin:~/work/shell$ bash find_length.sh
enter the string : linux_ubuntu
the length of the entered string linux_ubuntu is 12


No comments:

Post a Comment