var_1="hi"
var_2="bye,hi,hello"
if [[ "$var_1" == *"$var_2"* ]];
then
echo "value of var_1 in var_2";
else
echo "sad =(";
fi
I would like check second variable contains first. That prints "Sad =(", why?
The condition checks that $var_1 consists of $var_2, possibly preceded and followed by something. But it's the other way round.
if [[ $var_2 = *"$var_1"* ]]
# ~ ~
== not = but yes (it's a typo question)awk where x=3 is an assignment and x==3 is a test/conditional ... ?
var_1that should be intovar_2if [[ "$var_2" =~ "$var_1" ]];