[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash script problems

From: Chris F.A. Johnson
Subject: Re: bash script problems
Date: Wed, 11 May 2005 21:29:37 -0400 (EDT)

On Thu, 12 May 2005, Tony Jo wrote:

Oh sorry. Didn't look at it closely enough.

Thanks, that did solve most of the issues,

   What did? Please quote enough of the previous post that we can tell
   what you are referring to.

but now I'm just wondering if the following is valid?

   Does it work?

temp=`expr $val1 + $val2`
$temp > file

Everything besides this seems to be working fine now

   Does $temp contain a command or the result of a command? If it's a
   command, then it will work, but that's not what you have.

   You want either:

temp='expr $val1 + $val2'  ## $temp contains the literal command
$temp > file


temp=`expr $val1 + $val2`  ## $temp contains the output of the commnd
echo "$temp" > file

   Or, since you are using bash:

temp=$(( $val1 + $val2 ))

    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress

reply via email to

[Prev in Thread] Current Thread [Next in Thread]