•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,451 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,587 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1153 | Replies: 2
![]() |
•
•
Join Date: Oct 2007
Location: UK
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Is this all you're trying to do?
#! /bin/sh
var1=123
var2=2000
echo `expr $var1 + $var2`
exit 0
#! /bin/sh
var1=123
var2=2000
echo `expr $var1 + $var2`
exit 0
No. That he can already do, but that will lose the decimal places (i.e. expr is, essentially, int only).
Try
Try
result=`echo "scale=2;${var1}+${var2}" | bc` Last edited by masijade : Oct 18th, 2007 at 8:57 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- C command-line I/O question (C++)
- Script use command mail (Shell Scripting)
- DOS "ROUTE" command (Visual Basic 4 / 5 / 6)
- command line (OS X)
- Graphics Card issues Stop Command??? (Windows NT / 2000 / XP / 2003)
Other Threads in the Shell Scripting Forum
- Previous Thread: Echoing the highest of ten inputed numbers.
- Next Thread: set ulimit inside of shell script



Linear Mode