To check for alphanumeric

Posted by Agnello | 2:28 AM

the bellow scrip will chek if yu input is alphanumeric

#!/bin/bash -x

echo -n "Enter alphanumeric input: "
read input

compressed="$(echo $input | sed -e 's/[^[:alnum:]]//g')"

if [ "$compressed" != "$input" ] ; then
echo "Input not valid."
else
echo "Input valid."
fi

--
Regards
Agnello Dsouza
www.linux-vashi.blogspot.com
www.bible-study-india.blogspot.com

0 comments