Unix/Linux Go Back    


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 !!

[Solved] How to calculate in sun bash

UNIX for Dummies Questions & Answers


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-12-2012
Pieter0815 Pieter0815 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 7 March 2014, 5:28 AM EST
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
[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

Moderator's Comments:
Please view this code tag video for how to use code tags when posting code and data.

Last edited by vbe; 10-12-2012 at 04:27 AM.. Reason: code tags..
Sponsored Links
    #2  
Old Unix and Linux 10-12-2012
rangarasan's Unix or Linux Image
rangarasan rangarasan is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 24 February 2015, 3:14 AM EST
Location: Chennai, India
Posts: 496
Thanks: 9
Thanked 124 Times in 120 Posts
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 Linux
Sponsored Links
    #3  
Old Unix and Linux 10-12-2012
Pieter0815 Pieter0815 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 7 March 2014, 5:28 AM EST
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Thank you. It works.
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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



All times are GMT -4. The time now is 11:17 AM.