#!/bin/bash a=$1 b=$2 while [ $b -ne 0 ]; do x=$((a % b)) a=$b b=$x done echo $a