On Sat, Jun 24, 2000 at 04:27:47AM -0500, Paul Sack <[EMAIL PROTECTED]> wrote:

| Although if you know bash scripting it is quite trivial to do:
| 
| for i in *.1; do 
| mv -f `echo $i | sed 's/1/3/'` `echo $i | sed 's/1/4/'`       # mv *.3->*.4
| mv -f `echo $i | sed 's/1/2/'` `echo $i | sed 's/1/3/'`       # mv *.2->*.3
| mv -f $i `echo $i | sed 's/1/2/'`                     # mv *.1->*.2
| mv -f `echo $i | sed 's/.1//'` $i                     # mv *->*.1
| done

You made that much more work than it needed to be.

Also, your code will break if there are any digits in filenames that
need rotating.

Try this -

   for i in *.1; do
      NAME=`echo $i | sed 's/\.1$//`
      mv -f ${NAME}.3 ${NAME}.4 
      mv -f ${NAME}.2 ${NAME}.3 
      mv -f ${NAME}.1 ${NAME}.2 
      mv -f ${NAME}   ${NAME}.1 
      killall -HUP syslogd
   done

Of course, you still need to have the .1 files existing first, because
that's how it decides what needs wrapping and what doesn't.

If you want to give it a list of files to wrap, you can do this -

   for NAME in messages maillog secure whatever whatever whatever; do
      mv -f ${NAME}.3 ${NAME}.4
      mv -f ${NAME}.2 ${NAME}.3
      mv -f ${NAME}.1 ${NAME}.2
      mv -f ${NAME}   ${NAME}.1
      killall -HUP syslogd
   done

-- 
Doug McLaren, [EMAIL PROTECTED]
Madness takes its toll.  Please have exact change.

---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to