Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to perform a basic arithmetics from unix csh/tcsh shell

Under windows, when I need to perform a basic calculations, I use a built-in calculator. Now I would like to find out what is the common way if you only have a shell.

Thanks

like image 880
vehomzzz Avatar asked Nov 27 '22 22:11

vehomzzz


1 Answers

From this web page (for csh and derivatives, since you asked):

% @ x = (354 - 128 + 52 * 5 / 3)
% echo Result is $x
Result is 174

and

% set y = (354 - 128 + 52 / 3)
% echo Result is $y
Result is 354 - 128 + 52 / 3

notice the different results.

Personally, I stick to /bin/sh and call awk or something (for maximal portability), or others have exhibited the bash approach.

like image 168
dmckee --- ex-moderator kitten Avatar answered Dec 21 '22 06:12

dmckee --- ex-moderator kitten