Validating a credit card number using Luhn's algorithm
if [ $(($i%2)) -eq 0 ] ; then foo=bar; else arr[$char]=$double


Then foo=bar? In any case, an alternative way of writing this is something like (borrowing your final if statement):

[[ $resultchecknum == $checknum ]] &amp;&amp; echo "CC Number is valid!" \
                                    || echo "CC Number is not valid."


Also, you have a mix of echo "..." | bc and bc &lt;&lt;&lt; "...", I suggest keeping to the latter as it simpler to write.

A similar alternative to if-then-else is using &amp;&amp;:

[ ! $(($i%2)) -eq 0 ] &amp;&amp; arr[$char]=$double