Differences between shell script variable assignment and C language variable assignment

in C, you can occasionally see variable assignments as follows:

x1 = x2 = 1;

this means that the variable x1 is equal to the variable x2 is equal to 2, and the execution is the same thing as

x1 = 1;
x2 = 1;

but in shell script assignment, meaning is different, if the command line x1 = x2 = 1, then the expression means the variable x1 is equal to x2 = 1, where x2 = 1 this is a string as a whole, there is no x2 variable, the test is as follows:

[email protected]:~$ Test1=Test2=1
[email protected]:~$ 
[email protected]:~$ echo $Test1
Test2=1
[email protected]:~$ echo $Test2

[email protected]:~$ 
[email protected]:~$ 

note: under the shell, only the value before the first equals sign is a variable, followed by the value of the variable.


Read More: