Linux – C shell mode operator

C shell mode operator… here is a solution to the problem.

C shell mode operator

I

know the C shell is very unfriendly, but I stick with it. So can someone help me with this syntax error that should be simple? I want to use the modulus operator in the C shell. So the command is like this, it keeps giving me syntax errors for the expr command.

set aVAr =`expr $number * 2 % $frequency`

I

found that I can enter “expr 6 % 5” and “expr 3 * 2”. However, I can’t use the command as “expr 3 * 2 %5”. What’s wrong with it ? I think CSH should be a table that takes three operands at the same time? Thank you very much,

Solution

expr is a command, not part of CSH. You must escape * to prevent CSH from trying to extend it, as in

set aVAr =`expr $number \* 2 % $frequency`

Related Problems and Solutions