ok - I'm headed in the right direction.  Since I only have one file to
deal with, I can forego the loop operation.  I see that I can use
grep and cut to pull the expiration date/time from the file, and use
the date command to get something from the operating system to compare
it to.  The only problem now is that the date/time in the file are GMT,
and the server is set to local time (CSTCDT).  It's not my machine so I
can't change it.

How can I convert from GMT to local (or vice versa) once I have a
date/time sitting in a variable?  Or do I need to do it before hand?
Or what?  (clues appreciated)

Marc Mutz wrote:
> 
> Marc Mutz wrote:
> >
> <snip>
> > this lacks time{,zones} and probably fails on files with multiple
> > numerical values on lines that contain 'expires'. But you can always
> > adjust the eval regexp (l.7) and the date timeformat (l.3) to fit your
> > needs.
> >
> <snip>
> 
> Richard Adams wrote:
> >
> <snip>
> >
> > Marc Mutz sent a mail saying for starters, that inspired me,
> <interrupted>
> I said "as a starter", not "for starters", but anyway, you are problably
> right. The syntax for the expiration date in the files was just "use the
> number that can be found in the same line as the 'expires' string". To
> actually implement the syntax in Jim's original mail you use
> 
> 1> #!/bin/bash
> 2> # echos all names of files that have expired
> 2a> #removes all files that reach their remove-date
> 3> now=$(date +'%Y%m%d%H%M')
> 4> for i in "$@"; do
> 5>   grep -iE 'expires|remove' "$i" | \
> 6>   while read; do
> 8>     removes=$(expr match "$REPLY" '.*Remove:\([0-9]+\);.*')
> 7>     expires=$(expr match "$REPLY" '.*Expires:\([0-9]+\);.*')
> 9>     [ "$removes" -a "$removes" -lt "$now" ] && rm -f "$i" && break
> 9a>    [ "$expires" -a "$expires" -lt "$now" ] && echo $i
> 0>   done
> 1'> done | uniq
> 
> This will find all occurences of Expires:<date>; and Remove:<date>;
> rules and act accrdingly, except when an expires tag is given on a line
> that precedes the line with the remove tag and both are older than $now.
> In this case the filename is printed (indicating expiration), but the
> corresponding file has been deleted.
> 
> You could split the script into one that removes files and one that
> prints expired files. Or you could hack l.1' to become
> 
> 1'> done | uniq | while read; do [ -f "$REPLY" ] && echo "$REPLY"; done
> 
> which is IMO ugly, but Unixish :-)
> 
> Marc
> 
> --
> Marc Mutz <[EMAIL PROTECTED]>        http://marc.mutz.com/Encryption-HOWTO/
> University of Bielefeld, Dep. of Mathematics / Dep. of Physics
> 
> PGP-keyID's:   0xd46ce9ab (RSA), 0x7ae55b9e (DSS/DH)
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
> the body of a message to [EMAIL PROTECTED]
> Please read the FAQ at http://www.linux-learn.org/faqs

-- 
Regards,
Jim Reimer - WA5RRH
[EMAIL PROTECTED]
http://www.webzone.net/jdreimer

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs

Reply via email to