Re: days-between
From: Ted Breen (ted_breen_at_team.telstra.com)
Date: 01/07/04
- Next message: Bill Marcum: "Re: TCSH weirdness with sed"
- Previous message: those who know me have no need of my name: "Re: How to write file names with cyrill characters?"
- In reply to: Chris F.A. Johnson: "Re: days-between"
- Next in thread: Chris F.A. Johnson: "Re: days-between"
- Reply: Chris F.A. Johnson: "Re: days-between"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 7 Jan 2004 17:21:34 +1100
Chris F.A. Johnson wrote in message ...
>On Wed, 07 Jan 2004 at 03:21 GMT, Ted Breen wrote:
>>
>> Chris,
>> I put the two changes to date1 and date2 and the original script now
>> seems OK.
>> I am having some trouble running the new script with #!/bin/sh.
>> I get a list of files interspersed with the maths.
>
> The list of files is probably because a variable is not quoted;
> the quick solution is to add "set -f" at the beginning of the
> sript.
With "set -f" I get
days_between.cfj 07/01/2004 19/01/2004
$(( $(( ( 1461 * ( 2004 + 4800 + ( 01 - 14 ) / 12 ) ) / 4 + ( 367 * ( 01 -
2 - 12 * ( ( 01 - 14 ) / 12 ) ) ) / 12 - ( 3 * ( ( 2004 + 4900 + ( 01 - 14 )
/ 12 ) / 100 ) ) / 4 + 19 - 32075 )) - $(( ( 1461 * ( 2004 + 4800 + ( 01 -
14 ) / 12 ) ) / 4 + ( 367 * ( 01 - 2 - 12 * ( ( 01 - 14 ) / 12 ) ) ) / 12 -
( 3 * ( ( 2004 + 4900 + ( 01 - 14 ) / 12 ) / 100 ) ) / 4 + 07 - 32075 )) ))
>
> Are you sure that's a Korn shell?
No. Only that the man sh says that it is.
The software has not been updated for many years.
>
> If it's not, you should get a syntax error (Bourne shell):
>
>$ echo $(( 3 + 4 ))
>syntax error: `(' unexpected
> Try a simple addition:
>
>echo $(( 4 + 4 ))
> Or even:
>eval echo $(( 4 + 4 ))
The default shell is csh
I put #!/bin/sh at the start of the script. and also tried #!/sbin/sh.
4% echo $(( 3 + 4 ))
Variable syntax
5% sh
$ echo $(( 3 + 4 ))
$(( 3 + 4 ))
$ eval echo $(( 4 + 4 ))
$(( 4 + 4 ))
$ ^D
6% eval echo $(( 4 + 4 ))
Variable syntax
7% which sh
/sbin/sh
8% ls -la /sbin/sh
-rwxr-xr-x 1 root sys 390564 Jan 28 1999 /sbin/sh
9% which ksh
/sbin/ksh
10% ls -la /sbin/ksh
lrwxr-xr-x 1 root sys 2 Jan 28 1999 /sbin/ksh -> sh
It's great to see that the original script has been updated but it probably
should have the date
in the comment so that this discussion makes sense.
>
> Chris F.A. Johnson http://cfaj.freeshell.org
> ===================================================================
> My code (if any) in this post is copyright 2004, Chris F.A. Johnson
> and may be copied under the terms of the GNU General Public License
- Next message: Bill Marcum: "Re: TCSH weirdness with sed"
- Previous message: those who know me have no need of my name: "Re: How to write file names with cyrill characters?"
- In reply to: Chris F.A. Johnson: "Re: days-between"
- Next in thread: Chris F.A. Johnson: "Re: days-between"
- Reply: Chris F.A. Johnson: "Re: days-between"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|