I'm trying to write a program that will ask the user to input the number of values he wants, prompt him for the values and then print out the maximum value and the minimum value.
This is what I have so far:

count=1
echo "Enter number of integers"
read n


while [ $count -le $n ]
do
        echo "Enter integer"
        read x

        current=$x

        if [ $current -gt $x ];
        then
                max=$current
        fi

        if [ $current -lt $x ];
        then
                min=$current
        fi
done


echo "Max value is $max"
echo "Min value is $min"

You set current=$x and then look for $current to be something other than $x. What you probably want is to check if [ $current -gt $max ] and if [ $current -lt $min ]. Other than that your logic looks in order.

commented: wrong answer +0