How can i loop my bash if statment until it meets the requirement

The code works if you do bash launch_script.sh 5 6 but if i do bash launch_script.sh 6 5 it asks for new start value but it doesn’t use it in the script – the script just ends.

#!/bin/bash
a=$1
b=$2
if [ $1 -gt $2 ]
then 
    echo "$1 is bigger then $2, plz input new start number"
    read -p "You're start number will be?: "
else
    until [ $a -gt $b ];
    do
        echo $a
        ((a++))
    done
fi


Source: bash

Leave a Reply