1
#!/bin/bash
echo "Enter any string"
read string
string1 = $(echo $string | rev)
if ["$string" == "$string1"]
then
     echo "String is palindrome"
else
     echo "String is not Palindrome"
fi

I am trying to check whether a string is a palindrome or not. Below is the error I get:

# ./palindrome.sh
Enter any string
mom
./palindrome.sh: line 5: string1: command not found
./palindrome.sh: line 6: [mom: command not found
String is not Palindrome
fpmurphy
  • 4,636

0 Answers0