LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   a new shell for doing mathematical operation (https://www.linuxquestions.org/questions/linux-newbie-8/a-new-shell-for-doing-mathematical-operation-822649/)

tubu_cuteguy 07-28-2010 10:51 AM

a new shell for doing mathematical operation
 
hello frendz,
I am working on a project which is based on doing mathematical operation
on the existing shell
for example for addition in the shell
without writing expr'$a+$b '
i want to do simple calculation
such as
c=a+b;



please help me

GrapefruiTgirl 07-28-2010 10:52 AM

Perhaps:

Code:

c=$((a+b))
does what you need?

imagine_me2 07-28-2010 02:10 PM

You could also use the "bc" utility, try man bc for details.

pixellany 07-28-2010 02:45 PM

Quote:

Originally Posted by tubu_cuteguy (Post 4048067)
hello frendz,
I am working on a project which is based on doing mathematical operation
on the existing shell
for example for addition in the shell
without writing expr'$a+$b '
i want to do simple calculation
such as
c=a+b;



please help me

We would love to help you!! What is your question?

In addition to the other suggestions here, have you looked at Python?

makyo 07-28-2010 06:56 PM

Hi.
Quote:

psh is a Perl program which executes a read-eval loop with enough
options so that general behavior reasonably similar to more traditional
shells like 'sh' or 'bash' can be achieved, while still allowing arbi-
trary perl expressions to be evaluated.
-- excerpt from man psh, q.v.
For a simple interactive example:
Code:

% psh
psh% $a=2
psh% $b=3
psh% $c=$a*$b
psh% print "$c\n";
6

Best wishes ... cheers, makyo

fbobraga 07-28-2010 07:16 PM

I think that python shell/interpreter is what you are looking for: http://docs.python.org/release/2.5.2...00000000000000


All times are GMT -5. The time now is 05:39 PM.