Re: [opensuse] Bash script problem regarding with some math

2008-01-13 Thread Aaron Kulkis
Linda Walsh wrote: Randall R Schulz wrote: One my 10.0 system: % while true; do hwclock; sleep 10; done Tue 11 Dec 2007 10:25:14 AM PST -0.877900 seconds Tue 11 Dec 2007 10:25:25 AM PST -0.988284 seconds Tue 11 Dec 2007 10:25:36 AM PST -0.983046 seconds On my 10.3 system: % while true; do

Re: [opensuse] Bash script problem regarding with some math

2007-12-12 Thread Linda Walsh
Randall R Schulz wrote: One my 10.0 system: % while true; do hwclock; sleep 10; done Tue 11 Dec 2007 10:25:14 AM PST -0.877900 seconds Tue 11 Dec 2007 10:25:25 AM PST -0.988284 seconds Tue 11 Dec 2007 10:25:36 AM PST -0.983046 seconds On my 10.3 system: % while true; do hwclock; sleep 10;

Re: [opensuse] Bash script problem regarding with some math

2007-12-12 Thread Aaron Kulkis
Randall R Schulz wrote: On Tuesday 11 December 2007 02:32, Carlos E. R. wrote: ... Both have good man pages. And info pages. Gack! WTF is with the FSF and their insistance on scrimping on the man pages, and only putting the detailed documentation in the info pages. And worse,

Re: [opensuse] Bash script problem regarding with some math

2007-12-12 Thread Carlos E. R.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The Wednesday 2007-12-12 at 09:54 -0800, Linda Walsh wrote: Interesting -- using same version of hwclock same kernel version, I compared 3 machines: one machine averaged around -0.988xxx, another -0.991xxx and a third at -0.0003xx. (the

Re: [opensuse] Bash script problem regarding with some math

2007-12-11 Thread Carlos E. R.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The Monday 2007-12-10 at 22:55 -0500, Carl Hartung wrote: On Mon December 10 2007 09:34:34 pm Carlos E. R. wrote: Obviously, it is thinking it is an octal number. How do I convince bash to use standard base ten math? Is there a prefix? Hi

Re: [opensuse] Bash script problem regarding with some math

2007-12-11 Thread Carlos E. R.
-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,

Re: [opensuse] Bash script problem regarding with some math

2007-12-11 Thread Carl Hartung
On Tue December 11 2007 05:20:29 am Carlos E. R. wrote: Yes! Thanks! :-) [EMAIL PROTECTED]:~ echo $[ (00 - 00)*3600 + (21 - 21)*60 + (10#08 - 10#09) ] -1 DIFF=$[ (10#$LOC_H - 10#$HWC_H)*3600 + (10#$LOC_M - 10#$HWC_M)*60 + (10#$LOC_S - 10#$HWC_S) ] Yes, of course. Done. Wish I were

Re: [opensuse] Bash script problem regarding with some math

2007-12-11 Thread Carlos E. R.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The Tuesday 2007-12-11 at 06:18 -0500, Carl Hartung wrote: Wish I were more confortable with google... didn't know what to tell it to search. You're welcome! FWIW, I first tried searching the advanced bash scripting guide. The answer was there

Re: [opensuse] Bash script problem regarding with some math

2007-12-11 Thread Anders Johansson
On Tuesday 11 December 2007 11:32:17 Carlos E. R. wrote: 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).

Re: [opensuse] Bash script problem regarding with some math

2007-12-11 Thread Randall R Schulz
On Tuesday 11 December 2007 02:32, Carlos E. R. wrote: The Monday 2007-12-10 at 21:22 -0800, Randall R Schulz wrote: ... 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 Two things: 1) Field

Re: [opensuse] Bash script problem regarding with some math

2007-12-11 Thread Carlos E. R.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The Tuesday 2007-12-11 at 10:28 -0800, Randall R Schulz wrote: set `/sbin/hwclock --show` HWC=$4 Two things: 1) Field four of the output from hwclock is the year. In mine, it is 'HH:MM:SS'. See: /sbin/hwclock --show set `/sbin/hwclock

Re: [opensuse] Bash script problem regarding with some math

2007-12-11 Thread Carlos E. R.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The Tuesday 2007-12-11 at 19:21 +0100, Anders Johansson wrote: HWC=$(/bin/date -d $(/sbin/hwclock --show) +%s) LOC=$(/bin/date +%s) DIFF=$((LOC-HWC)) if test $DIFF -gt 1; then Wow. :-O So easy... However... I think the end result is not

[opensuse] Bash script problem regarding with some math

2007-12-10 Thread Carlos E. R.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I have a bash script with this line: DIFF=$[ ($LOC_H - $HWC_H)*3600 + ($LOC_M - $HWC_M)*60 + ($LOC_S - $HWC_S) ] to calculate a time difference in seconds. Well, when the seconds are 08 it fails: [EMAIL PROTECTED]:~ echo $[ (00 - 00)*3600

Re: [opensuse] Bash script problem regarding with some math

2007-12-10 Thread Carl Hartung
On Mon December 10 2007 09:34:34 pm Carlos E. R. wrote: Obviously, it is thinking it is an octal number. How do I convince bash to use standard base ten math? Is there a prefix? Hi Carlos, A bit of Google research reveals the prefix '10#' tells bash to use base 10 (decimal) instead octal

Re: [opensuse] Bash script problem regarding with some math

2007-12-10 Thread Randall R Schulz
On Monday 10 December 2007 18:34, Carlos E. R. wrote: Hi, I have a bash script with this line: DIFF=$[ ($LOC_H - $HWC_H)*3600 + ($LOC_M - $HWC_M)*60 + ($LOC_S - $HWC_S) ] to calculate a time difference in seconds. Well, when the seconds are 08 it fails: As Carl mentioned, BASH acts like