A.Compare two strings.
B.Join two Strings.
C.Find the length of the given Strings.
D.Find occurrence of character and word
E.Reverse the strings.
B.Join two Strings.
C.Find the length of the given Strings.
D.Find occurrence of character and word
E.Reverse the strings.
clear echo "STRING MANIPULATION PROGRAM" echo "1. COMPARE STRING" echo "2. JOINT TWO STRING" echo "3. LENGTH OF STRING" echo "4. OCCOURANCE OF CHARACTER" echo "5. OCCOURANCE OF WORD" echo "6. REVERSE STRING" echo "ENTER CHOICE:" read ch case $ch in 1) echo "ENTER FIRST STRING:" read str1 echo "ENTER SECOND STRING:" read str2 len1=`echo $str1 | wc -c` len2=`echo $str2 | wc -c` if [ $len1 -eq $len2 ];then echo "BOTH STRINGS ARE OF SAME LENGTH" elif [ $len1 -gt $len2 ];then echo "$str1 is greater than $str2" else echo "$str2 is greater than $str1" fi ;; 2) echo "ENTER FIRST STRING:" read str1 echo "ENTER SECOND STRING:" read str2 str1="$str1$str2" echo "COMBINED STRING : $str1" ;; 3) echo "ENTER STRING:" read str len=`echo $str | wc -c` echo "Length of string is $len" ;; 4) echo "ENTER STRING:" read str echo "ENTER character of word to search:" read search len=`echo $str | wc -c` i=1 while [ $i -lt $len ] do ch=`echo $str | cut -c $i` echo $ch i=`expr $i + 1` done ;; 5) echo "NOT THERE" ;; 6) echo "ENTER STRING:" read str echo "REVERSE STRING IS : "`echo $str | rev` ;; *) echo "ENTER PROPER CHOICE" echo "NOT THERE" ;; esacOutput:
0 comments:
Post a Comment