Im beginner in shell scripting and im trying to achieve following , if i pass two numbers as argument for example = 0 5 , the console will output 1 2 3 4 5 , but if i pass 5 0 , console should output 5 4 3 2 1 , the first one works nice , but the second one does nothing in my script , it does not throw any arror.
script
if [[ $1 -lt $2 ]]; then
for((i=$1;i<$2;i++))
do
if [[ "$i" -lt $2 ]]; then
echo -n "$i "
else
echo -n "$i"
fi
done
else
for((i=$2;i>=$1;i--))
do
if [[ "$i" -gt $1 ]]; then
echo -n "$i "
else
echo -n "$i"
fi
done
fi
as i said the first condition works - numbers are 0 5 for example but the second when first number is greater than second does not . how can i fix it?
0 1 2 3 4 5in the first case, and vice versa; or4 3 2 1 0in the second case?