[Solved] Problem with if-then-else loop

Hi,

i have a problem with this script:

for i in $(cat list_ip_switch)
do
        if
                if [ $i -eq "10.155.249.173" ]; then
                echo "found ip"
        else
                echo "not found ip"
        fi
done
cat list_ip_switch

10.155.249.171
10.155.249.172
10.155.249.173
10.155.249.174

you have one if too much here but sure its a typo...
the problem comes from -eq which is normally for equal to, but for numeric value (integer...) which is not the case here (the shell is seeing a string...)
Im sure you replace by = and it should work...

If input file is long, then it's better to use io redirect. I use always while + read when use file input.

while read i xstr
do
        if [  "$i"  =  "10.155.249.173" ]; then
                echo "found ip"
        else
                echo "not found ip"
        fi
done < list_ip_switch

Why read i xtsr ?
It's not have to, but:
if line include ip and something else then 1st value is in the i and rest of line is in the xtsr.

thanks works!