[NTLUG:Discuss] Script question

Steve Baker sjbaker1 at airmail.net
Sat Jan 5 00:04:17 CST 2002


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




More information about the Discuss mailing list