Link to home
Start Free TrialLog in
Avatar of nocturn4l
nocturn4l

asked on

Bourne Shell - if someone enters a variable that begins with...

sorry, i know my questions are kind of basic, but i'm hoping you guys can help out

lets say if the user enters something that begins with "BL" but can be anything like BLsdf or BLUE or something..how can i figure this out?  I know it should be something along the lines of "BL"* or something but i'm not sure... if someone can point me in the right direction

i'm really trying to learn here

#!/bin/sh
echo -n "Enter a color: "
read color
if [ $color = bl* ]
then
 echo "blue"
fi

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nocturn4l
nocturn4l

ASKER

thanks again ozo, you're awesome.  is this something you can only do using case instead of 'if'?  still learning here, thanks again.
if expr "$color" : 'bl*' ; then echo blue ; fi
thank you!  learning alot from everyone here