if else


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting if else
# 1  
Old 02-26-2012
if else

Hi,
i am trying to write a scripts in bash......if own is right or wrong then it should echo valid and if i pass any other then that......then it should echo invalid.

pls help
my code is ----
Code:
echo "ENTER OWNER NAME "
read own
if ["$own" == 'right']  ||  ["$own" == 'wrong']
then
  echo "valid"
else
  echo "invalid"
fi


Last edited by Scott; 02-26-2012 at 05:03 AM.. Reason: Code tags, please...
# 2  
Old 02-26-2012
Hi, use single = signs and use proper spacing around the brackets..

Code:
if [ "$own" = 'right' ] || [ "$own" = 'wrong' ]

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 02-26-2012
Thanx......its working Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question