I need to do an exercise at the university, its all about reading 3 values and identify if there is any duplicated value, which value is the greatest and which one is the least, the idea is if you input any duplicated values the shell should print a message and stop doing the calculations but I can´t get this part done.
here is the code:
#!/bin/sh
echo " A value "
read A
echo " B value "
read B
echo " C value "
read C
# Print the input
echo " INPUT "
echo " A = $A "
echo " B = $B "
echo " C = $C "
# search duplicated values
if [[ $A -eq $B ]] || [[ $A -eq $C ]];then
echo " Duplicated values please check "
elif [[ $B -eq $A ]] || [[ $B -eq $C ]];then
echo " Duplicated values please check "
elif [[ $C -eq $A ]] || [[ $C -eq $B ]];then
echo " Duplicated values please check "
fi
# greatest value
if [[ $A -gt $B ]] || [[ $A -gt $C ]];then
echo " A $A +"
elif [[ $B -gt $A ]] || [[ $B -gt $C ]];then
echo " B $B +"
elif [[ $C -gt $A ]] || [[ $C -gt $B ]];then
echo " C $C +"
fi
# less value
if [[ $A -lt $B ]] || [[ $A -lt $C ]];then
echo " A $A -"
elif [[ $B -lt $A ]] || [[ $B -lt $C ]];then
echo " B $B -"
elif [[ $C -lt $A ]] || [[ $C -lt $B ]];then
echo " C $C -"
fi
Right now if I enter a duplicated code for example A=3 B=5 C=3
the code do the calculations and print that there exist duplicated values and I need just the message telling me that I have introduced duplicated values.
How can I get this done ?
Thank you for your help.