Newsgroups: comp.unix.shell
Path: utzoo!utgpu!watserv1!maytag!maytag!himacdon
From: himacdon@maytag.uwaterloo.ca (Hamish Macdonald)
Subject: Re: Using imbedded commands inside expr(1)
In-Reply-To: wrp@PRC.Unisys.COM's message of 8 Nov 90 04:56:33 GMT
Message-ID: <1990Nov8.135809.16688@maytag.waterloo.edu>
Sender: daemon@maytag.waterloo.edu (Admin)
Organization: University of Waterloo, Waterloo, Ontario
References: <1462@eastman.UUCP> <15525@burdvax.PRC.Unisys.COM>
Date: Thu, 8 Nov 90 13:58:09 GMT
Lines: 28

>>>>> In article <15525@burdvax.PRC.Unisys.COM>, wrp@PRC.Unisys.COM
>>>>> (William R. Pringle) writes:

William> In article <1462@eastman.UUCP> gerwitz@kodak.com (Paul
William> Gerwitz) writes:
>I seem to be having trouble using expr.  The following dies:
>
>    test=`expr `tail +3 file` + 1` 
>
>    Basically get a numeric value from a file and increment it,
>    putting the result in a shell variable.

William> The backslash can be used to quote nested backward quotes
William> (and other strange characters):

William> 	test=`expr \`tail +3 file\` + 1`

When using the Korn shell (as the original poster is), I think it is
less confusing to use the $() form of command substitution:

	test=$(expr $(tail +3 file) + 1)

William> Bill Pringle

Hamish.
--
--------------------------------------------------------------------
himacdon@maytag.uwaterloo.ca                 watmath!maytag!himacdon
