@IRJ lmao that's intense. You must have missed the updated one. It asks you how many numbers to generate with this one. If the number you're using is huge you may want to use /dev/urandom instead of $RANDOM%, which I think can only generate a number as big as like 37,000 or something?

@bnrstnr said in How can a split a number into unequal parts?:

Here's your script to specify how many numbers to generate

`#!/bin/bash echo "How many numbers to generate?" read -r quant; echo "Enter Number"; read -r num; step="2"; answer=$(((RANDOM % $num)+1)); newnum=$(expr "$num" - "$answer"); total=$answer; string="$answer"; while [ $step -lt $quant ] do answer=$(((RANDOM % $newnum)+1)); newnum=$(expr "$newnum" - "$answer"); string="$string"+"$answer"; total=$(expr "$total" + "$answer"); ((step++)); done answer=$(expr "$num" - "$total"); string="$string"+"$answer"; echo $string;`

There is a chance that you could generate a random number right out the gate that's too large to allow the number you specified... you could just rerun the script and try again at that point