- A numeric value is assigned to a variable the same way strings are assigned. The value will be treated as a number by the methods that access it:
#!/bin/bash no1=4; no2=5;
- The let command is used to perform basic operations directly. Within a let command, we use variable names without the $ prefix. Consider this example:
let result=no1+no2 echo $result
Other uses of let command are as follows:
- Use this for increment:
$ let no1++
- For decrement, use this:
$ let no1--
- Use these for shorthands:
let no+=6 let no-=6
These are equal to let no=no+6 and let no=no-6, respectively.
- Alternate methods are as follows:
The [] operator is used in the ...