Addition In Bash Link to heading

Integers Link to heading

# Use the $(( )) arithmetic expansion.
day_number=$(fd "day-([1-9]+)" "$path" | wc -l)
day_number=$((day_number + 1))

num=$((num1 + num2))
num=$(($num1 + $num2))       # Also works
num=$((num1 + 2 + 3))        # ...
num=$[num1+num2]             # Old, deprecated arithmetic expression syntax

# Using the external expr utility. Note that this is only needed for really old systems.
num=`expr $num1 + $num2`     # Whitespace for expr is important

Floating Point Link to heading

num=$(awk "BEGIN {print $num1+$num2; exit}")
num=$(python -c "print $num1+$num2")
num=$(perl -e "print $num1+$num2")
num=$(echo $num1 + $num2 | bc)   # Whitespace for echo is important