Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i=1
- while [ $i=1 ]
- do
- echo "--------------------"
- echo "1. Compare String"
- echo "2. Combine String"
- echo "3. Find Length Of The String"
- echo "4. Reverse The String"
- echo "5. Occurance a Particular Word"
- echo "6. Exit"
- echo "--------------------"
- echo -n "Enter Your Option :"
- read ch
- case $ch in
- 1) echo "Compare String"
- echo -n "Enter First String : "
- read str1
- echo -n "Enter Second String : "
- read str2
- if [ $str1 = $str2 ]
- then
- echo "--------------------"
- echo "String is Same"
- echo "--------------------"
- else
- echo "--------------------"
- echo "String is Not Same"
- echo "--------------------"
- fi
- ;;
- 2) echo "Combine String"
- echo -n "Enter First String : "
- read strc1
- echo -n "Enter Second String : "
- read strc2
- echo "$strc1 $strc2"
- ;;
- 3)echo "Find Length Of The String"
- echo -n "Enter String :"
- read string
- len=`echo $string | wc -c`
- len=`expr $len - 1`
- echo $len
- ;;
- 4)echo "Reverse The String"
- echo -n "Enter String :"
- read str
- revs=`echo -n $str | rev`
- echo $revs
- ;;
- 5)echo "Occurance a Particular Word"
- echo -n "Enter String : "
- read ostr
- echo -n "Enter Word : "
- read word
- file1=`echo $ostr | cat > str.lst`
- wrd=`grep -o $word str.lst | cat > occ.lst`
- count=`grep -c $word occ.lst`
- echo $count
- ;;
- 6)echo "Exit"
- exit
- ;;
- *) echo "Enter Proper Choice"
- ;;
- esac
- echo -n "Enter 2 to Exit :"
- read i
- if [ $i -ne 1 ]
- then
- exit
- fi
- done
Add Comment
Please, Sign In to add comment