Difference between "&&" inside variable and outside variable in shell script

Viewed 803

Just out of curiosity:

A="echo hi"
B="echo hello"
C="$A && $B"

echo $C // prints "echo hi && echo hello"
$C
echo "$A && $B" // prints "echo hi && echo hello"
$A && $B

I though this would work in a same manner. But it shows different results as this:

echo hi && echo hello
hi && echo hello
echo hi && echo hello
hi
hello

Why?

1 Answers
Related