Re: Doing a modulo in /bin/sh??
From: Philip Hallstrom (freebsd_at_philip.pjkh.com)
Date: 08/31/05
- Previous message: Gary Kline: "Doing a modulo in /bin/sh??"
- In reply to: Gary Kline: "Doing a modulo in /bin/sh??"
- Next in thread: Gary Kline: "Re: Doing a modulo in /bin/sh??"
- Reply: Gary Kline: "Re: Doing a modulo in /bin/sh??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Aug 2005 11:18:57 -0700 (PDT) To: Gary Kline <kline@tao.thought.org>
> 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
_______________________________________________
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"
- Previous message: Gary Kline: "Doing a modulo in /bin/sh??"
- In reply to: Gary Kline: "Doing a modulo in /bin/sh??"
- Next in thread: Gary Kline: "Re: Doing a modulo in /bin/sh??"
- Reply: Gary Kline: "Re: Doing a modulo in /bin/sh??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]