[NTLUG:Discuss] Script question
Paul Ingendorf
pauldy at wantek.net
Sat Jan 5 06:12:40 CST 2002
It could be done that way this was just the way I choose to do it.
BTW it would have to be a lot closer to midnight than one or two seconds. Although I agree it is safer to assign it to a var and just use the var. The better deal would be to simply pass the file as an argument from whatever script creates it.
-----Original Message-----
From: discuss-admin at ntlug.org [mailto:discuss-admin at ntlug.org]On Behalf
Of Steve Baker
Sent: Saturday, January 05, 2002 12:04 AM
To: discuss at ntlug.org
Subject: Re: [NTLUG:Discuss] Script question
Paul Ingendorf wrote:
>
> hmm shell scripts yum gotta throw in how I would do it even though I see a few fine examples have already been posted.
> The following would also move the files appropriately. Just copy and paste this in a file chmod +x it and remember to create the new backup file as /archive/domains.`date +%Y-%m-%d` and it should work properly every time.
>
> #!/bin/bash
> rm -f /archive/*.3
> let x=3
> for file in /archive/domains.[0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9].[0-3]
> do
> mv $file /archive/`echo $file | sed -e "s/\.[0-9]^//g"`.$x
> let x=$x-1
> done
> mv /archive/domains.`date +%Y-%m-%d` /archive/`date +%Y-%m-%d`.0
Just don't run this within a second or two of midnight!
I think the last line should be replaced by:
FNAME=/archives/domains.`date +%Y-%m-%d`
mv ${FNAME} ${FNAME}.0
I'll forgive you for your Y10K bug though! :-)
----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1 at airmail.net> WorkMail: <sjbaker at link.com>
URLs : http://www.sjbaker.org
http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
http://prettypoly.sf.net http://freeglut.sf.net
http://toobular.sf.net http://lodestone.sf.net
_______________________________________________
http://www.ntlug.org/mailman/listinfo/discuss
More information about the Discuss
mailing list