|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
[Solved] How to calculate in sun bash
I have two problems, and it would be great if someone could help me: The first line does not calculate. I have checked the origin term to calculate the variables and the result is OK. Normal substactions with $xx -100 work, but not in this constallation. I tried it with "| bc" and no result too. Code:
x= $((y - z)) echo "$x" a=`echo "$x"-10 | bc` echo "$a" And the comparison does not work, I tried -bg with no result too Code:
if [ `echo "$a" > 0 | bc` ] then sendme /rsi/logs/csc_summary_size_check.log stefan.madre fi Thanks for your help
Last edited by vbe; 10-12-2012 at 04:27 AM.. Reason: code tags.. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
bash
Hi, Welcome to the unix and linux forum !! Please use code tags for your data samples and code. Try this one, Code:
First way:
x=1
y=2
z=0
((z=x+y))
echo ${z}
Second way:
x=1
y=2
z=0
z=$(echo "$x+$y"|bc)
echo ${z}Cheers, Ranga
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thank you. It works.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calculate the number of days between 2 dates - bash script | kovacsakos | Shell Programming and Scripting | 3 | 09-13-2012 06:49 PM |
| [Solved] Bash test 2 variables to see if ones greater by n | jaysunn | Shell Programming and Scripting | 2 | 03-13-2012 01:19 PM |
| Calculate the day after bash | karkov | UNIX for Dummies Questions & Answers | 9 | 01-29-2012 04:11 AM |
| [Solved] Using SSH in bash script | colinireland | Shell Programming and Scripting | 0 | 10-19-2011 04:39 PM |
| [SOLVED] how to use my aliases in a bash script | xib.be | Shell Programming and Scripting | 0 | 11-29-2010 03:46 PM |
|
|