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

0

1 Answer 1

1

Try double brackets :

if [[ "$var1" == *"$var2"* ]]; then
.....
Sign up to request clarification or add additional context in comments.

2 Comments

Yep that worked! Could you explain why? Thanks!
great... here is some info... serverfault.com/questions/52034/… ...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.