division in shell scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting division in shell scripts
# 1  
Old 11-28-2005
division in shell scripts

Iam not able to device variables in a shell script..
here is the lines that i tried.. please help..

sum = echo `expr $up / ( $down )`
# 2  
Old 11-28-2005
Quote:
Originally Posted by esham
Iam not able to device variables in a shell script..
here is the lines that i tried.. please help..

sum = echo `expr $up / ( $down )`
Try like this,

sum=$(print "scale = 2; $up/$down" | bc)
# 3  
Old 11-28-2005
try

$ sum=`expr $up / $down`
$ echo $sum
# 4  
Old 11-28-2005
Try this

div=$(($x / $y))

This will store the result of division in the div variable.

Regards,
Rahul.
# 5  
Old 11-28-2005
Quote:
Originally Posted by ashterix
try

$ sum=`expr $up / $down`
$ echo $sum
You will not get decimal points with this solution if the $down value is greater than $up value.
# 6  
Old 11-30-2005
print command is not found message is coming.
my division will give less that 0 value..
so what to do..
any other option for print
# 7  
Old 11-30-2005
Replace the print with echo.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to perform floating division in shell script?

I want to perform the below division operation in shell script and round the value. val1=6000 val2=5000 res=val1/val2 ----> 1.2---> Round to 2 Please help. (3 Replies)
Discussion started by: vel4ever
3 Replies

2. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

3. UNIX for Dummies Questions & Answers

New to shell scripts

Hi, Probably a real easy one for someone...I need to have a scheduled cp job run from crontab to copy certain files and directories to a shared NFS storage. The script I have works fine, except I need to exclude certain directories to stop issues with symbolic links, can someone explain... (2 Replies)
Discussion started by: paul.duncalf
2 Replies

4. Shell Programming and Scripting

Shell Scripts

deleted (1 Reply)
Discussion started by: zxc
1 Replies

5. Shell Programming and Scripting

division operation in shell script

Hi guys I am trying to divide 2 variables that I got during the execution of script, but I unable to divide the variables. pls help. Hers is the code. num_tasks=`sqlplus -s batch_user/batch_user@acsblest << EOF1 set heading off SET FEEDBACK OFF SET PAGESIZE 0 SET LINESIZE 900 select... (31 Replies)
Discussion started by: ragha81
31 Replies

6. Shell Programming and Scripting

Help With Shell Scripts

if I run the below mentioned code, i am getting error. I dunno why. plz help me out this code runs a sql query and sends the result by email #!/bin/ksh # # Purpose: - Report Workflows that have Persistence turned ON echo "Workflow Persistence Report Started: `date '+%Y%m%d_%H%M%S'`" >>... (6 Replies)
Discussion started by: ragha81
6 Replies

7. Shell Programming and Scripting

Need Help With Shell scripts

Hello, I'm very very fresh with unix, and I would like to get familiar with it. I want to know what is Shell scripting and how other programming languages connects with it. And is there any way to learn the shell scripting, with some book and some simulator to practice on. Thanks ahead. (2 Replies)
Discussion started by: holler1
2 Replies

8. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

9. Shell Programming and Scripting

shell scripts help

Hi, I am not experienced in shell scripts, I hope someone can give some hint for the following problem I have html file like this <html> <body> Some stuff More stuff <pre> A B </pre> Still more stuff And more <pre> C D </pre> Additional stuff </body> (2 Replies)
Discussion started by: ccp
2 Replies

10. UNIX for Dummies Questions & Answers

about shell scripts

Hi, i have made a script which makes some analyses on some differnet hosts. but i have a problem to make this script more quicker ... i would like to enter more a one hosts in the query (in my script are this: Pls enter the Hostname ... read hostname for i in $hostname do echo... (5 Replies)
Discussion started by: scottl
5 Replies
Login or Register to Ask a Question