Converting string to int doesn't work properly in terminal Converting string to int doesn't work properly in terminal.

I want to find how much time specific string occur in a big string. 

if ((echo "iOS/i" | grep -o iOS/ | wc -l | bc)&gt;2) then echo "ThreeOrMore"; else echo"TwoOrLess"; fi


result 

ThreeOrMore


But the result actually should be TwoOrLess

but inner part works well

echo "iOS/i" | grep -o iOS | wc -l | bc


result 

1
You can't use &gt; to compare numbers in bash (&gt; is used to redirect output to a file), you need to run the comparison as part of a test/[ command. Also the call to bc doesn't seem to do anything, echo "iOS/i" | grep -o iOS | wc -l already outputs 1.

The updated snippet looks like this (split on several lines for easier readability):

if [ $(echo "iOS/i" | grep -o iOS/ | wc -l) -gt 2 ]; then
    echo "ThreeOrMore"
else
    echo "TwoOrLess"
fi