Operating System - HP-UX
1822781 Members
4011 Online
109645 Solutions
New Discussion юеВ

how can i calculate in c-shell?

 
Maurice Skubski
Trusted Contributor

how can i calculate in c-shell?

Hi, i want to make a calculation in c-shell: $v1 - 2 where $v1 is for example 10. how do i write the result in a new variable. thanx for help :)
TIP: ITO was renamed to VPO. And now with Version 7 it is renamed to OVO (OpenView Operations)
7 REPLIES 7
Alexander M. Ermes
Honored Contributor

Re: how can i calculate in c-shell?

Hi there.


export V1="10"
export V2="0"
$V2=`expr $V1 - 2`

Rgds
Alexander M. Ermes
.. and all these memories are going to vanish like tears in the rain! final words from Rutger Hauer in "Blade Runner"
Volker Borowski
Honored Contributor

Re: how can i calculate in c-shell?

%setenv V1 4
%setenv RESULT `expr $V1 - 2`
%echo $RESULT
2

Quotes are backwards.

Volker
Maurice Skubski
Trusted Contributor

Re: how can i calculate in c-shell?

sorry, this is not working :( export error. do i have to define the export command or the variable? i'm not realy good in c-shell. thanx :)
TIP: ITO was renamed to VPO. And now with Version 7 it is renamed to OVO (OpenView Operations)
Volker Borowski
Honored Contributor

Re: how can i calculate in c-shell?

Maurice,

in the c-shell, you have to use
"setenv VARIABLE value"
with NO equal-sign !

"export VARIABLE=value"
is Bourne or Kornshell Syntax.

Volker
Maurice Skubski
Trusted Contributor

Re: how can i calculate in c-shell?

hmm, is there a good homepage whith a c-shell tutorial? i think, i have to lern a bit more c-shell. thank you for help :)
TIP: ITO was renamed to VPO. And now with Version 7 it is renamed to OVO (OpenView Operations)
Tom Danzig
Honored Contributor

Re: how can i calculate in c-shell?

#!/usr/bin/csh

@ v1 = 10
@ z = $v1 - 2
echo $z


The @ sign defines numeric (integer) variables
Sachin Patel
Honored Contributor

Re: how can i calculate in c-shell?

set t=1
set t1=5
echo "$t + $t1"|bc

Sachin
Is photography a hobby or another way to spend $