Afficher un message
Vieux 12/09/2007, 01h19   #7
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to compare dates and notify

Cyrus Kriticos wrote:
> littlehere@gmail.com wrote:
>
>> I am trying to put together a script to compare the dates of a file
>> and send out an email notification if the date on the file is beyond
>> 30 calendar days. However, I am having a bit of trouble. The file
>> format is <filename>_%m%d%y. So for example
>> foobar1_090207
>> foorbar2_090307
>> foorbar3_091507

>
> ^^
> future? typo?
>
>> I parse the file so I am just left with the date extension from
>> there I want to be notified of any file over the 30 day mark.
>>
>> I tried using expr and setting up a variable for the 30 days but its
>> not working. Any would be appreciated. Thanks.

>
>
> [bash]
>
>
> $ FILENAME="foobar1_090207"
> $ TIME="${FILENAME#*_}"
>
> $ PAST="$(date -d "20${TIME:4:2}-${TIME:0:2}-${TIME:2:2}" +'%s')"
> $ NOW=$(date -d $(date +'%Y-%m-%d') +'%s')


$ NOW=$(date -d $(date +'%Y-%m-%d') +'%s') ; echo $NOW
1189552546

$ NOW=$(date +'%s') ; echo $NOW
1189552546

You're thinking too complex, I suppose. :-)
(Or any trick I am missing?)

Janis

>
> $ let DIFF=(NOW-PAST)/60/60/24
> $ echo "diff in days: $DIFF"
> diff in days: 9
>

  Réponse avec citation
 
Page generated in 0,05624 seconds with 9 queries