Skip to content

Absolute value

Print the absolute value of an integer.

18th August 2026

abs() {
  (( $1 < 0 )) && echo "$(( $1 * -1 ))" || echo "$1"
}