From owner-freebsd-questions@FreeBSD.ORG Wed Aug 31 18:19:06 2005 Return-Path: X-Original-To: freebsd-questions@FreeBSD.ORG 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 35A1C16A420 for ; Wed, 31 Aug 2005 18:19:06 +0000 (GMT) (envelope-from freebsd@philip.pjkh.com) Received: from zhonka1.zhonka.net (zhonka1.zhonka.net [66.228.195.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id B38FE43D4C for ; Wed, 31 Aug 2005 18:19:03 +0000 (GMT) (envelope-from freebsd@philip.pjkh.com) Received: from wolf.pjkh.com ([66.228.196.74]) by zhonka1.zhonka.net (Post.Office MTA v3.5.3 release 223 ID# 0-58414U4500L450S0V35) with ESMTP id net; Wed, 31 Aug 2005 11:19:02 -0700 Received: from localhost (localhost [127.0.0.1]) by wolf.pjkh.com (Postfix) with ESMTP id 7AA09584D; Wed, 31 Aug 2005 11:18:57 -0700 (PDT) Received: from wolf.pjkh.com ([127.0.0.1]) by localhost (wolf.pjkh.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01813-02; Wed, 31 Aug 2005 11:18:57 -0700 (PDT) Received: by wolf.pjkh.com (Postfix, from userid 1000) id 4B67F584B; Wed, 31 Aug 2005 11:18:57 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by wolf.pjkh.com (Postfix) with ESMTP id 469495773; Wed, 31 Aug 2005 11:18:57 -0700 (PDT) Date: Wed, 31 Aug 2005 11:18:57 -0700 (PDT) From: Philip Hallstrom To: Gary Kline In-Reply-To: <20050831181545.GA57907@thought.org> Message-ID: <20050831111755.V2009@wolf.pjkh.com> References: <20050831181545.GA57907@thought.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at pjkh.com Cc: FreeBSD Mailing List Subject: Re: Doing a modulo in /bin/sh?? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2005 18:19:06 -0000 > I can grab the results of "w=$date+%U)"; in C an use the modulo > operator; is there a way to do this is /bin/sh? ot zsh? > > tia, guys, > > gary > > #/bin/sh > w=$(date +%U) > echo "w is $w"; > (even=$(w % 2 )); ## flubs. > echo "even is $even"; ## flubs. > > if [ $even -eq 0 ] ## flubs, obv'ly. > then > echo "week is even"; > else > echo "week is odd"; > fi Take a look at 'expr'.... philip@foxtrot:~ % expr 1 % 2 1 philip@foxtrot:~ % expr 2 % 2 0