Calculate modulo in sh script
If your sh really is sh and not just bash being run as sh then this will work just fine
if [ `expr $n % 5` -eq 0 ]
then
# do something
fi
If your sh is really bash then put your test in (( ))
like so
if (( $n % 5 == 0 ))
then
# do something
fi
You should use bc when doing math in shell
if [ `echo "3 % 2" | bc` -eq 0 ]