From owner-freebsd-questions@FreeBSD.ORG Sat Feb 19 16:23:12 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EDFA416A4CE for ; Sat, 19 Feb 2005 16:23:12 +0000 (GMT) Received: from cadmuslabs.net (68.143.26.91.nw.nuvox.net [68.143.26.91]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4990443D54 for ; Sat, 19 Feb 2005 16:23:12 +0000 (GMT) (envelope-from scott.milliken@e-comsultant.net) Received: from [192.168.2.2] (stunnel@localhost.e-comsultant.net [127.0.0.1]) (authenticated bits=0) by cadmuslabs.net (8.12.9p2/8.12.8) with ESMTP id j1JGNAfS000334 for ; Sat, 19 Feb 2005 10:23:11 -0600 (CST) (envelope-from scott.milliken@e-comsultant.net) Message-ID: <42175A14.3000402@e-comsultant.net> Date: Sat, 19 Feb 2005 10:24:04 -0500 From: Scott Milliken User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <20050219125559.3bb98715@ale.varnet.bsd> In-Reply-To: <20050219125559.3bb98715@ale.varnet.bsd> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: How to handle numeric variables in sh? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Feb 2005 16:23:13 -0000 Here's a code snippet of a script I use often to number a bunch of pics in a directory that I think shows how to do what you want to do: $PICNUM=100 for FNAME in DSC*.JPG do NEWNAME=My_Pictures-$PICNUM.jpg mv $FNAME $NEWNAME PICNUM=$(($PICNUM+1)) done This works in /bin/sh from my FreeBSD 4.11 system and also bash. If you want to perform a mathematical operation on a shell variable, just surround the expression with $(( expr )) and it'll work. Hope that helps. Scott Milliken Alejandro Pulver wrote: >Hello, > >Is there a way to handle numeric variables (addition, multiplication, etc.) in 'sh' (or throught an external command)? > >Thanks and Best Regards, >Ale >_______________________________________________ >freebsd-questions@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-questions >To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > >!DSPAM:42176184998836675110134! > > >