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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if expr "$color" : 'bl*' ; then echo blue ; fi
ASKER
thank you! learning alot from everyone here
ASKER