Afficher un message
Vieux 12/09/2007, 19h05   #14
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to compare dates and notify

On Wed, 12 Sep 2007 14:17:44 -0000, littlehere@gmail.com
<littlehere@gmail.com> wrote:
>
>
> I changed the script around a bit to search for all the files and go
> through them. Problem is is only reads and works on the one file so
> the dates are returning as the same. Any ideas?
>
> #!/bin/bash
> FILENAME=`ls /<path_to_file>| grep _[0-9]` (this produces foo_090407
> foo_090507 foo_090607)
> for i in $FILENAME
> do
> TIME="${FILENAME#*_}"

TIME="${i#*_}"

> PAST="$(date -d "20${TIME:4:2}-${TIME:0:2}-${TIME:2:2}" +'%s')"
> NOW=$(date -d $(date +'%Y-%m-%d') +'%s')
> let DIFF=(NOW-PAST)/60/60/24
> echo "$i diff in days: $DIFF"
> done
>
> The above produces
> foo_090407 diff in days: 8
> foo_090507 diff in days: 8
> foo_090607 diff in days: 8
>



--
Include me out.
  Réponse avec citation
 
Page generated in 0,05000 seconds with 9 queries