•
•
•
•
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,441 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,607 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: 1135 | Replies: 6
![]() |
•
•
Join Date: Nov 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Dear friends ,
file is test.sh
its give result 2+4 not 6 so plz tell how can i get the right result
sanjay
file is test.sh
echo expr 2+4;
its give result 2+4 not 6 so plz tell how can i get the right result
sanjay
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
•
•
Join Date: Oct 2007
Posts: 306
Reputation:
Rep Power: 2
Solved Threads: 29
If you're using a more advanced shell than posix or sh, you can use "let" also - just a suggestion 
let var=2+4
echo $var
let works the opposite of expr, in so far as the spaces go - you shouldn't put any spaces between operators and operand
, Mike

let var=2+4
echo $var
let works the opposite of expr, in so far as the spaces go - you shouldn't put any spaces between operators and operand
, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
You can also, as long as it is not csh or sh, just simply do
var=$(( 2 + 4 ));
var=$(( $var + 2 ));
var=$(( 2 + 4 ));
var=$(( $var + 2 ));
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)
Similar Threads
- Installing Windows 98 On VMware. Floppy problem (Windows 9x / Me)
- "use" statement inside an eval: problem? (Perl)
- problem with displaying in HANDLE C.. (C)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP / 2003)
- Problem with compiler (C)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Gadgets and Gizmos)
- Connection Problems (Networking Hardware Configuration)
- Problem with Windows Update and WinXP (Web Browsers)
Other Threads in the Shell Scripting Forum
- Previous Thread: Helpless in shell sorting
- Next Thread: Could use some help



Linear Mode