Reputation: 11
cat sample.sh
a=$1
if [ "$a" = "Dhinakaran Ramu" ];then
echo "Present"
else
echo "Not Present"
fi
sample.sh Dhinakaran Ramu
Answer is "Not Present"
Upvotes: 1
Views: 37
Reputation: 188
It worked executing
sample.sh "Dhinakaran Ramu"
Note: if we execute
sample.sh Dhinakaran Ramu
then the script receives not one argument, but two. In the script you use $1, because you expect one argument.
Upvotes: 1
Reputation: 151
Make sure when you run the script, send the text in quotation marks:
$ ./sample.sh "Dhinakaran Ramu"
Upvotes: 1
Reputation: 2601
When you run the script $1 is Dhinakaran and $2 is Ramu. Try
sample.sh "Dhinakaran Ramu"
Upvotes: 0