Corrected solution IF_METRIC=1 for router in $new_routers; do metric_arg="metric $IF_METRIC" route add default dev $interface gw $router $metric_arg IF_METRIC=$(( $IF_METRIC+1 )) done