Afficher un message
Vieux 31/05/2007, 17h48   #2
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: date function current month and last month the same

2007-05-31, 08:28(-07), wolffc@gmail.com:
> I have a process the uses the date function to get the last month and
> the current month. Here are the functions
>
> set x = `date -d "-1 month" +%b`
> set y = `date -d "0 month" +%b`
>
> For some reason x and y are both May. Does this have something to do
> with May being 31 days? This had been working all of April and all of
> May. I am using csh

[...]

Yes, that's probably the reason.

You can do (sh syntax):

LC_ALL=C date +%bDecJanFebMarAprMayJunJulAugSepOctNovDec |
sed 's/\(...\).*\(...\)\1.*/\2/'

I'd recommend not to use csh for scripting.

--
Stéphane
  Réponse avec citation
 
Page generated in 0,05919 seconds with 9 queries