Uploaded January 2022 | Updated November 2026, 4 days ago
In this video we cover doing simple math/calculations in bash using integers (whole numbers) and variables. Variables were covered in the previous video. We use mostly brackets for calculations, due it's simplicity, but you can also use other commands like, let, bc, declare, printf and awk.
#terminal #bash #bashscripting #linux
https://itvraag.nl
Timestamp:
0:00 Intro
0:16 bash challenge #2 answer
0:53 bash commands for calculation
1:23 using brackets
2:06 math with variables
2:47 increment or decrement
3:15 calculate with multiple variables
3:35 calculate using let command
3:44 calculate date
4:09 bash challenge #3
Relevant videos:
Bash #4 - variables: youtu.be/mOSnZ7zOF3g
Bash #3 - script files: youtu.be/ajpTOFyeDH4
Bash #2 - help, touch, echo & aliases: youtu.be/cyi6imc5ruY
Bash #1 - basic concepts: youtu.be/C-HwzPVLo1c
Used links and commands:
echo $((2+2))
echo $((4-11))
echo $((3*2))
echo $((18/3))
echo $((1/3))
echo $((2/3))
echo $(( (8*2) / (5-1) ))
x=22
((x++))
echo $((x--))
((x/=2))
echo $((x=44,x/=4))
x=$((x+2))
x=22;y=3
((a=x*y,b=a+11))
echo $x $y $a $b
echo $((x=22,y=3,a=x*y,b=a+11))
newDate=$(date -d "+10 days")
echo $newDate
Arithmetic Operator Description
*, /, % multiplication, division, remainder
+, - addition, subtraction
id++, id– post-increment & -decrement
++id, –id pre-increment & -decrement
==, != equality, inequality
& AND
| OR
&& logical AND
|| logical OR
In this video we cover doing simple math/calculations in bash using integers (whole numbers) and variables. Variables were covered in the previous video. We use mostly brackets for calculations, due it's simplicity, but you can also use other commands like, let, bc, declare, printf and awk.
#terminal #bash #bashscripting #linux
https://itvraag.nl
Timestamp:
0:00 Intro
0:16 bash challenge #2 answer
0:53 bash commands for calculation
1:23 using brackets
2:06 math with variables
2:47 increment or decrement
3:15 calculate with multiple variables
3:35 calculate using let command
3:44 calculate date
4:09 bash challenge #3
Relevant videos:
Bash #4 - variables: youtu.be/mOSnZ7zOF3g
Bash #3 - script files: youtu.be/ajpTOFyeDH4
Bash #2 - help, touch, echo & aliases: youtu.be/cyi6imc5ruY
Bash #1 - basic concepts: youtu.be/C-HwzPVLo1c
Used links and commands:
echo $((2+2))
echo $((4-11))
echo $((3*2))
echo $((18/3))
echo $((1/3))
echo $((2/3))
echo $(( (8*2) / (5-1) ))
x=22
((x++))
echo $((x--))
((x/=2))
echo $((x=44,x/=4))
x=$((x+2))
x=22;y=3
((a=x*y,b=a+11))
echo $x $y $a $b
echo $((x=22,y=3,a=x*y,b=a+11))
newDate=$(date -d "+10 days")
echo $newDate
Arithmetic Operator Description
*, /, % multiplication, division, remainder
+, - addition, subtraction
id++, id– post-increment & -decrement
++id, –id pre-increment & -decrement
==, != equality, inequality
& AND
| OR
&& logical AND
|| logical OR










