0

Simple enough issue but I cannot seem to solve it. I need the below to be True.

var1="was shot by skeleton"
var2="was shot by"

if [ "$var1" == "$var2" ]; then
    echo "true"; else
    echo "false"
fi

I have Tried putting "*" beside var2 but no luck.

Thanks, Simon

Mat
  • 202,337
  • 40
  • 393
  • 406
Simon Kay
  • 111
  • 1
  • 1
  • 8

1 Answers1

1

Try double brackets :

if [[ "$var1" == *"$var2"* ]]; then
.....
iamauser
  • 11,119
  • 5
  • 34
  • 52