Linux and Networking

Linux and Networking

4.20. C-style variables.

We already know a lot of things about shell script if we have seen the previous articles but not all. The truth is that Bash still keeps many secrets.

For C or Java programmers, I am going to tell you that there is a style of variable manipulation very similar to these languages. Let’s look at an example of this:

 

$((a=33))

$echo $a

33

$ (( a++ ))

$echo $a

  1. 4

$ (( ++a ))

$echo $a

35

$ (( a– ))

$echo $a

  1. 4

$ (( –a ))

$echo $a

33

$ (( a+=15 ))

$echo $a

48

 

Suggested exercise:

Copy and run the above code. Take the opportunity to make certain changes to the code and try another operator

The Demeter Project