-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The Monday 2007-12-10 at 21:22 -0800, Randall R Schulz wrote:
As Carl mentioned, BASH acts like the C and C++ compilers in that a
leading 0 signifies octal (base 8) numeric literals and a 0x prefix
signifies hexadecimal (base 16).
'Ox' I knew, but '0' for octal I forgot. Perhaps I always though it was
'Ou', not 'zero'. I never tried, as I never had use for octal.
You say you're doing temporal math. You might want to look at
whether "date" makes this easier for you. It can do some temporal math.
I know, and I tried. But didn't find a way to do it.
If you are curious, what I'm doing is compare the CMOS clock with the
system clock, to prove it doesn't stray:
set `/sbin/hwclock --show`
HWC=$4
set `/bin/date +%T`
LOC=$1
HWC_H=`echo $HWC | /usr/bin/cut --characters=1-2`
HWC_M=`echo $HWC | /usr/bin/cut --characters=4-5`
HWC_S=`echo $HWC | /usr/bin/cut --characters=7-8`
LOC_H=`echo $LOC | /usr/bin/cut --characters=1-2`
LOC_M=`echo $LOC | /usr/bin/cut --characters=4-5`
LOC_S=`echo $LOC | /usr/bin/cut --characters=7-8`
DIFF=$[ (10#$LOC_H - 10#$HWC_H)*3600 + (10#$LOC_M - 10#$HWC_M)*60 + (10#$LOC_S
- 10#$HWC_S) ]
if test $DIFF -gt 1 ; then
logger -p daemon.error -t CLOCK -- CMOS clock differs $DIFF\" at $HWC
fi
Which now I think could be wrong... because DIFF could be negative and it
wouldn't trigger.
perhaps:
if test $DIFF -gt 1 -o $DIFF -lt -1 ; then
Or maybe there is something to get the absolute value.
Also, when the math required in shell scripts gets more than a little
complicated, I usually switch to "dc". It's very flexible, though it
uses reverse polish notation, so you have to either like HP calculators
(I do) or learn to readjust your thinking about how you express
arithmetic expressions.
Argh. No, I was a TI calculator type chap (TI 57, 58C...), never could use
an HP. And I later found Casio (FX-850), so I can't/won't use anything
else :-p
...
Oh, all right. I should mention "bc," too. It does infix. If you're into
that sort of thing.
That's better ;-)
No, I do not need that, for now, but I keep that info somewhere in the
back of my mind.
Both have good man pages.
And "info" pages.
- --
Cheers,
Carlos E. R.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
iD8DBQFHXmcztTMYHG2NR9URAl4nAKCWcXuwQKGJijTy6kkB7ZqQhNTF3gCfSFZD
hnZw1wfelEyiBEsc8UmObbA=
=HxG9
-----END PGP SIGNATURE-----
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]