Tutorial by Examples

let let num=1+2 let num="1+2" let 'num= 1 + 2' let num=1 num+=2 You need quotes if there are spaces or globbing characters. So those will get error: let num = 1 + 2 #wrong let 'num = 1 + 2' #right let a[1] = 1 + 1 #wrong let 'a[1] = 1 + 1' ...
#!/bin/bash echo $(( 1 + 2 )) Output: 3 # Using variables #!/bin/bash var1=4 var2=5 ((output=$var1 * $var2)) printf "%d\n" "$output" Output: 20
#!/bin/bash expr 1 + 2 Output: 3

Page 1 of 1