3000 explained code solutions for 75 technologies


bashHow to check if a string starts with a specific value


var="How to do it?"
if [[ $var == How* ]]; then echo "It starts with How"; fictrl + c
var="How to do it?"

define test string to check

$var == How*

check if $var starts with "How"

echo "It starts with How"

execute this code if $var really starts with How