June 2017
Beginner
502 pages
11h 26m
English
The comma operator chains together arithmetic operations or strings:
zarrelli:~$ x=$((5 + 10)) ; echo $x15zarrelli:~$ x=$((5 + 10, 6-1)) ; echo $x5zarrelli@moveaway:~$ x=$((y=25, 6-1)) ; echo "The value of x is $x and the value of y is $y"The value of x is 5 and the value of y is 25
What we can see here is that even though the operations are concatenated, only the value of the last one is returned. So, x is instanced with the value of just 6-1. But, as I mentioned before, we can use the comma character to concatenate strings:
zarrelli@moveaway:~$ for i in {,1}1 ; do echo $i ; done111zarrelli@moveaway:~$ for i in {,1}2 ; do echo $i ; done212zarrelli@moveaway:~$ for i in {,1,}2 ; do echo $i ; done2122zarrelli@moveaway:~$ ...Read now
Unlock full access