Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
echo "Enter a number"
read n

while [ $n -gt 0 ]
    sd=$(( $n % 10 ))
    rev=$(( $rev *\ 10 + $sd ))
    n=$(( $n / 10 ))

echo "Reverse number of entered digit is $rev"

From the above code I am unable to get the required output. Instead, this error is displayed.

./Display: line 17: 0 *\ 10 + 4 : syntax error: operand expected (error token is "\ 10 + 4 ")
Reverse number of entered digit is 0

I don't know why this error is displayed, please help me to figure it out.

share|improve this question
*\ is not a valid arithmetic operator in bash. What is your expected input and output? –  Chris Down Feb 24 '13 at 6:27

4 Answers 4

Numbers are text too. Text can be reversed with rev without any arythmetic.

read -p "Enter a number: " num
echo $num | rev
share|improve this answer

The error had already pointed out the problem clearly: 0 *\ 10 + 4 isn't a valid arithmetic expression when shell try to evaluate it.

I believe *\ is a typo of *, fix this typo and the script will be ok.

share|improve this answer

*\ is not the valid expression. Instead, try * which removes the special meaning of the character *. The character * is a wildcard character, which is why the error appeared.

share|improve this answer

* is a wildcard character. Hence make sure that you add a '\' before using it

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.