answersLogoWhite

0

len=0

i=1

echo -n "Enter a String: "

read str

len=`echo $str | wc -c`

len=`expr $len - 1`

halfLen=`expr $len / 2`

while [ $i -le $halfLen ]

do

c1=`echo $str|cut -c$i`

c2=`echo $str|cut -c$len`

if [ $c1 != $c2 ] ; then

echo "string is not palindrome"

exit

fi

i=`expr $i + 1`

len=`expr $len - 1`

done

echo "String is Palindrome"

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
More answers

public boolean palindrome(String string)
{
boolean isPalindrome = true;
char[] Character = new char[string.length()]
character[] = string.toCharArray();
for(int i = 0;i < string.length(); i++)
{
if(character[i] != character[string.length()-i])
isPalindrome = false;

}

return isPalindrome;

}

User Avatar

Wiki User

15y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Shell script to check if a string is a palindrome?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Program to check that given string is palindrome or not in C?

/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }


Bluej program-read a string and check if the given string is a palindrome?

import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i&lt;failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}


How do you check given string is palindrome or not with out using string functions?

/*To check whether a string is palindrome*/includeincludevoid main () {int i,j,f=0;char a[10];clrscr ();gets(a);for (i=0;a[i]!='\0';i++){}i--;for (j=0;a[j]!='\0';j++,i--){if (a[i]!=a[j])f=1;}if (f==0)printf("string is palindrome");else printf("string is not palindrome");getch ();}


How do you check whether a string is palindrome or not using vb Script?

Private Sub Command1_Click() a = Text1.Text b = StrReverse(a) If a = b Then Print "palindrome" Else Print "not palindrome" End If End Sub


Write a pseudo logic to check whether a string is palindrome or not?

Prepare the string for processing: Remove all punctuation from the string (e.g., commas, hyphens, whitespace, etc). Convert to the same case (e.g., lower-case). Instantiate two pointers, one pointing at the first character, the other pointing at the last character. Process: If the two pointers are pointing at the same position or have crossed each other, the string is a palindrome. Otherwise, compare the characters being pointed at. If they are not equal, the string is not a palindrome. Otherwise, move both pointers one position towards the middle of the string and repeat the process.