Write shell scripts to find the length of a given string and to extract a substring from a given string.

  echo " ----To find the length of the given string----"

        echo "Enter the string"
        read str
        strlen=${#str}
        echo "The string length:$strlen"
       echo "--------Extraction of substring-------"
        echo "Enter starting position"
        read pos1
        echo "Enter how many characters u want:"
        read pos2
        substr=${str:$pos1:$pos2}
        echo "the substring:$substr" 

Comments