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: • Bash #4 - working with variables (wit...
Bash #3 - script files: • Bash #3 - Script files (with challenge)
Bash #2 - help, touch, echo & aliases: • Bash #2 - Help, touch, echo & aliases
Bash #1 - basic concepts: • Bash #1 - Basic concepts and requirem...
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
Смотрите видео Bash #5 - calculating with arithmetic operations & numbers (integers) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь itvraag 27 Январь 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 595 раз и оно понравилось 9 людям.