delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/03/22/15:32:22

X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Kevin Markle <kmarkle AT pbs DOT org>
Subject: Re: Doing additions in cygwin?
Date: Thu, 22 Mar 2007 16:31:07 -0400
Lines: 32
Message-ID: <mn.b3df7d73ab651e79.51129@pbs.org>
References: <mn DOT b3b57d733ae76d53 DOT 51129 AT pbs DOT org> <297343D29C14AA4D822142893ABEAEF302E4D041 AT srv1163ex1 DOT flightsafety DOT com>
Reply-To: kmarkle AT pbs DOT org
Mime-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

After serious thinking Thrall, Bryan wrote :
> Kevin Markle wrote on Thursday, March 22, 2007 2:49 PM:
>> Hello,
>> 
>> I'm attemping to use the expr variable and am having problems. when I
>> type test=expr 1+1 or
>> test=`expr 1+1` or
>> test='expr 1 + 1' or
>> 
>> with and without quotes?? I just want to create a variable based on
>> and expression?
>
> (1) You didn't really describe what problems you're seeing (I think I
> know what they are, though).
>
> (2) expr wants separate arguments, like "expr 1 + 1", not "expr 1+1".
>
> (3) use backtics to get the output when you set the variable:
> "test=`expr 1 + 1`", not "test='expr 1 + 1'".
>
> (4) This isn't really Cygwin-specific, so it would be better to try "man
> expr" (for how to use expr) or "man bash" (for quoting rules).
>
> Hope this helps!

Thanks!

I was able to get it to work by using variables instead of actual 
numbers. So I said num1=1 and num2=3 and then did expr $num1 + $num2 
and it work :-?




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019