The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help for Sed Syntax problem SanjayLinux Shell Programming and Scripting 2 10-15-2007 10:52 PM
syntax problem grepping? dsimpg1 Shell Programming and Scripting 9 07-17-2007 05:48 PM
Syntax problem with Unix ftp get command mheinen HP-UX 2 02-09-2007 10:01 AM
syntax problem rajan_ka1 Shell Programming and Scripting 3 03-08-2006 10:04 AM
multiple cuts syntax problem Gerry405 UNIX for Dummies Questions & Answers 12 10-31-2005 06:23 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-16-2006
Registered User
 

Join Date: Sep 2005
Posts: 130
syntax problem

Dear friends,


I am writing shell script in csh .


i want to make arthimatic operation in csh.

i wrote sysntax like this.
set val = 230
set tmp = `0.1 * $val + 300`
echo $tmp

but it is not working .

anyone please give me syntax.
Reply With Quote
Forum Sponsor
  #2  
Old 03-16-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
I dont think that csh supports direct math operations. You would have to use expr to do any math. And then expr does not support non integer operations.

Try doing something like this:
Code:
set val = 230
echo $val
set tmp = `echo 0.1 \* $val + 300|bc`
echo $tmp
Reply With Quote
  #3  
Old 03-16-2006
Registered User
 

Join Date: May 2005
Posts: 48
Use the '@' command in csh.

The '@' command in csh does processing of arithmetic expressions.

See the man page for csh.
Reply With Quote
  #4  
Old 03-16-2006
Registered User
 

Join Date: Mar 2006
Location: Durban, South Africa
Posts: 7
Google for ``Csh scripting considered harmful'' for some good reasons why you
should try to avoid scripting in csh.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0