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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multiply variables Anita Flejter Shell Programming and Scripting 2 05-06-2008 08:03 PM
gawk multiply one field pau Shell Programming and Scripting 2 05-28-2006 02:01 PM
How to add/multiply numbers with scientific notation (2.343e-5) chugger06 UNIX for Dummies Questions & Answers 1 01-26-2006 10:03 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-27-2007
fwabbly fwabbly is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 11
multiply variable

I need to multiply the value of a variable and then store it in another variable. I have EXPHOURINSEC=$(($EXPDATEHOUR * 3600)) but i get an error saying the * is unexpected.

Im using ksh
  #2 (permalink)  
Old 07-27-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
It should be

Code:
EXPHOURINSEC=$((EXPDATEHOUR * 3600))
  #3 (permalink)  
Old 07-27-2007
fwabbly fwabbly is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 11
thanks. its always the little things!
  #4 (permalink)  
Old 07-28-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by fwabbly View Post
thanks. its always the little things!

What little thing solved it for you? Your original line and all of the alternatives posted should work in ksh.

You would not have got the error message you gave with the line you posted if it was run in a POSIX shell (ksh, bash, etc.)

One alternative posted, EXPHOURINSEC=$((EXPDATEHOUR * 3600)), while a valid POSIX command, would not have worked in /bin/sh on a *BSD system.

  #5 (permalink)  
Old 07-27-2007
madmat madmat is offline
Registered User
  
 

Join Date: Aug 2005
Location: Paris
Posts: 80
Try :
EXPHOURINSEC=$((${EXPDATEHOUR}*3600))
without blanks
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0