How Can You Compare Multiple Strings in Shell Script
January 01 2015
This post is simple and helpful for how to compare multiple strings by shell scripting. For example can check the country name which one is available.
#!/bin/bash
echo -n "Enter Your Country Name :"
read countryname
if [ $countryname != "india" ] && [ "$countryname" != "usa" ] && [ "$countryname" != "japan" ] ; then
echo "";
echo "Your Country code does not match..."
exit 1;
else
echo "";
echo "The Country Name is Available : $countryname"
fi
Output :
Enter Your Country Name :
india
The Country Name is Available : india
Comments (0)