Check if Palindrome

Check if a string is a palindrome by comparing characters from both ends.

Code

Algorithms
clean=$(echo "$s" | tr '[:upper:]' '[:lower:]' | tr -cd 'a-z0-9')
reversed=$(echo "$clean" | rev)
[[ "$clean" == "$reversed" ]] && echo "true" || echo "false"

Parameters

The string to check

Server

More Bash Snippets