Docsity

Shell Script Programs to Find Palindrome and String Length, Exercises of Computer Vision

Toggle sidebar
bg1
EXP NO: 3
STRINGS Nikhil
1805103
DATE:24.09.2020
AIM
1. Write a shell script program to find a given string is palindrome or not.
echo "Input string:"
read str
for i in $(seq 0 ${#str}) ; do
revstr=${str:$i:1}$revstr
done
if [ "$str" = "$revstr" ]; then
echo "It is a palindrome."
else
echo "It is not a palindrome."
fi
Output:
2. Write a shell script program to find string length without using inbuilt function.
echo "Enter string:"
pf2

Partial preview of the text

Download Shell Script Programs to Find Palindrome and String Length and more Exercises Computer Vision in PDF only on Docsity!

EXP NO: 3

STRINGS Nikhil

DATE:24.09.

AIM

1. Write a shell script program to find a given string is palindrome or not.

echo "Input string:" read str for i in $(seq 0 ${#str}) ; do revstr=${str:$i:1}$revstr done if [ "$str" = "$revstr" ]; then echo "It is a palindrome." else echo "It is not a palindrome." fi

Output:

2. Write a shell script program to find string length without using inbuilt function.

echo "Enter string:"

read n len= for (( i=0; i<${#n}; i++ )); do let "len++" done echo "length=$len"

Output:

Result:

Thus, the required shell scripts have been executed and verified.