On Mon, 29 May 2000,  Jim Reimer wrote about,  shell script question:
> Given a file that contains a line indicating the date and
> time the file expires, in the form:
> 
> Expires:200005281430;Remove:200005281430;991272
> 
> (this example is 28 May, 2000 @ 1430Z)
> 
> can one easily determine with a shell script if the file
> has indeed expired, and then delete it?  I realize this
> would be a trivial task using C or Perl, but what about
> the standard command-line tools like grep, sed, and so on?

Marc Mutz sent a mail saying for starters, that inspired me, i like to use
the "kiss" method, keep it simple, The last word is not for resale, however,
Marc, your idea possably wont work, (forgive me for saying that)
should the date not be,
$(date +'%Y%m%d%H%M') ??
which should produce the same amount of numbers as the Expire line above.

I would do it in such a way.

#!/bin/sh
 
DATE=`date +%Y%m%d%H%M`
THERE=`cat filename | grep Expires:200005281430 | awk -F : '{ print $2 }'`
 
if [ ! "$DATE" -gt "$THERE" ]; then
 echo "The date has past Expire time."
else
 echo "Date is $DATE and FILE = $THERE" 
fi

Of course i am going on the principle that the expire time is to be found
in the file "filename".
You would need to subtitute the "echo's" with whatever you want,
Eg;
 rm /path/to/filename
else
 bla bla.
fi

The above is also for starters, i do however like the way Marc's script
works.
Or should work as i see it when one adds the hour and minute to the date
line.

Marc. ???


We chould get a reaction from California later on when the Olszewski's wake
up.

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

-- 
Regards Richard
[EMAIL PROTECTED]
http://people.zeelandnet.nl/pa3gcu/


-
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