DAYS OF THE MONTH

2013-07-12 Thread Max Power
Hi,
o.s.: OpenBSD 5.3/amd64

If I create a directory with the command: mkdir $(date +'%d')

why this is the result: 1, 2, 3, 4, 5, 6, 7, 08, 09, 10, etc.
Why the '0' [zero] appears only ahead the digit 8 and 9..?

Thanks.



Re: days of the month

2013-07-12 Thread Jérémie Courrèges-Anglas
Max Power open...@cpnetserver.net writes:

 Hi,

Hi. Please stop using all-caps mail subjects.

 o.s.: OpenBSD 5.3/amd64

 If I create a directory with the command: mkdir $(date +'%d')

You'd better put double quotes around your command substitutions rather
than simple quotes around fixed, non-special strings: $(date '+%d')

 why this is the result: 1, 2, 3, 4, 5, 6, 7, 08, 09, 10, etc.
 Why the '0' [zero] appears only ahead the digit 8 and 9..?

You must have done something wrong:

$ date -j +%d 2013701
01
$

See strftime(3).

-- 
Jérémie Courrèges-Anglas
PGP Key fingerprint: 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494



Re: days of the month

2013-07-12 Thread Max Power
 You must have done something wrong:
I have not done anything. The system is the default installation.

 You'd better put double quotes around your command substitutions rather
 than simple quotes around fixed, non-special strings: $(date '+%d')
Ok, but why the command: mkdir $(date +'%d') after the digit 7 works fine?

If I insert the date manually then it works fine - example: # date
20130707
but no by default. Why? thanks


 Max Power open...@cpnetserver.net writes:

 Hi,

 Hi. Please stop using all-caps mail subjects.

 o.s.: OpenBSD 5.3/amd64

 If I create a directory with the command: mkdir $(date +'%d')

 You'd better put double quotes around your command substitutions rather
 than simple quotes around fixed, non-special strings: $(date '+%d')

 why this is the result: 1, 2, 3, 4, 5, 6, 7, 08, 09, 10, etc.
 Why the '0' [zero] appears only ahead the digit 8 and 9..?

 You must have done something wrong:

 $ date -j +%d 2013701
 01
 $

 See strftime(3).

 --
 Jérémie Courrèges-Anglas
 PGP Key fingerprint: 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494



Re: days of the month

2013-07-12 Thread Jan Stary
On Jul 12 23:34:27, open...@cpnetserver.net wrote:
  You must have done something wrong:
 I have not done anything. The system is the default installation.
 
  You'd better put double quotes around your command substitutions rather
  than simple quotes around fixed, non-special strings: $(date '+%d')
 Ok, but why the command: mkdir $(date +'%d') after the digit 7 works fine?

Come back on the first of August,
with a script(1) in your hand.



Re: days of the month

2013-07-12 Thread Max Power
Forgive my fault and my English!
What I want to know is why [technically] the scipt: mkdir $(date +'%d'),
whith the default system date, with no manual insertion, return this
sequence of digits: 1, 2, 3, 4, 5, 6, 7, 08, 09, 10, etc.
Why the '0' [zero] appears only after the digit 7?

I hope I explained myself.
Thanks for the explanation and for your patience, Max Power.



 On Jul 12 23:34:27, open...@cpnetserver.net wrote:
  You must have done something wrong:
 I have not done anything. The system is the default installation.

  You'd better put double quotes around your command substitutions
 rather
  than simple quotes around fixed, non-special strings: $(date '+%d')
 Ok, but why the command: mkdir $(date +'%d') after the digit 7 works
 fine?

 Come back on the first of August,
 with a script(1) in your hand.



Re: days of the month

2013-07-12 Thread Michał Markowski
2013/7/12 Max Power open...@cpnetserver.net:
 You must have done something wrong:
 I have not done anything. The system is the default installation.

Try to reproduce this:

$ for i in `jot -w %02d 31 1`; do date -j +%d 201307${i}; done
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31



Re: days of the month

2013-07-12 Thread Jérémie Courrèges-Anglas
Max Power open...@cpnetserver.net writes:

 You must have done something wrong:
 I have not done anything.

Hey, you must have done *something*. Else you wouldn't be reporting
about it.  You just don't want to tell us *exactly* what you've done.

 The system is the default installation.

I'm not saying that you have fucked up your system.

 You'd better put double quotes around your command substitutions rather
 than simple quotes around fixed, non-special strings: $(date '+%d')
 Ok, but why the command: mkdir $(date +'%d') after the digit 7 works fine?

If you showed us the actual commands you use, we wouldn't have to guess.

To further explain what Jan said in an earlier mail: somewhere in your
script the number output by date(1) is interpreted while in an
arithmetic context, where numbers starting with '0' are interpreted as
octal, and their leading zero gets trimmed.  But this doesn't happen for
08 and 09 which aren't valid octal numbers.

~$ v=03; v=$(($v))
~$ echo $v
3
~$ v=08; v=$(($v))
ksh: 08: bad number `08'
~$ echo $v
08
~$

Hence the reference to August, where scripts that have worked fine so
far start failing with weird error messages.

 If I insert the date manually then it works fine - example: # date
 20130707

Now I can say that you're trying to fuck up your system. :)

 but no by default. Why? thanks

-- 
Jérémie Courrèges-Anglas
PGP Key fingerprint: 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494



Re: days of the month

2013-07-12 Thread Jan Stary
On Jul 12 23:54:56, open...@cpnetserver.net wrote:
 Forgive my fault and my English!
 What I want to know is why [technically] the scipt: mkdir $(date +'%d'),

That's not a script. That's a line from
some script which you haven't shown us.

 whith the default system date, with no manual insertion, return this
 sequence of digits:

That line doesn't return any sequence of digits,
it creates directories.

 1, 2, 3, 4, 5, 6, 7, 08, 09, 10, etc.
 Why the '0' [zero] appears only after the digit 7?

One might _guess_ that's where the 0n
is no longer a valid octal number, but
without seeing your broken script,
that's all: a guess.



Re: days of the month

2013-07-12 Thread Alexander Hall

On 07/13/13 00:06, Jérémie Courrèges-Anglas wrote:

Max Power open...@cpnetserver.net writes:


You must have done something wrong:

I have not done anything.


Hey, you must have done *something*. Else you wouldn't be reporting
about it.  You just don't want to tell us *exactly* what you've done.


The system is the default installation.


I'm not saying that you have fucked up your system.


You'd better put double quotes around your command substitutions rather
than simple quotes around fixed, non-special strings: $(date '+%d')

Ok, but why the command: mkdir $(date +'%d') after the digit 7 works fine?


If you showed us the actual commands you use, we wouldn't have to guess.

To further explain what Jan said in an earlier mail: somewhere in your
script the number output by date(1) is interpreted while in an
arithmetic context, where numbers starting with '0' are interpreted as
octal, and their leading zero gets trimmed.  But this doesn't happen for
08 and 09 which aren't valid octal numbers.

~$ v=03; v=$(($v))
~$ echo $v
3
~$ v=08; v=$(($v))
ksh: 08: bad number `08'
~$ echo $v
08
~$


My *guess*:

typeset -i

/Alexander



Hence the reference to August, where scripts that have worked fine so
far start failing with weird error messages.


If I insert the date manually then it works fine - example: # date
20130707


Now I can say that you're trying to fuck up your system. :)


but no by default. Why? thanks