? culling multiple backups of small editted files ?

? culling multiple backups of small editted files ?

Post by Eric Ols » Sun, 26 May 1996 04:00:00



Is there a good script to maintain the earliest and latest dated files and
delete the others?  As I edit my files, I automatically create
a unique backup named with the date and time.  Thanks for any pointers.

-rwx-- 1 eric ipusers  893 Apr 19 16:43 ..login.960419.16:43~.gz*  KEEP
-rwx-- 1 eric ipusers  890 Apr 20 11:46 ..login.960420.11:46~.gz*  KILL
-rwx-- 1 eric ipusers 1151 Apr 20 11:58 ..login.960420.11:58~.gz*  KILL
-rwx-- 1 eric ipusers 1158 Apr 20 12:03 ..login.960420.12:03~.gz*  KILL
-rwx-- 1 eric ipusers 1193 Apr 20 12:10 ..login.960420.12:10~.gz*  KILL
-rwx-- 1 eric ipusers 1193 Apr 22 17:02 ..login.960422.17:02~.gz*  KILL
-rwx-- 1 eric ipusers 1196 Apr 26 15:51 ..login.960426.15:51~.gz*  KEEP

--

--

 
 
 

? culling multiple backups of small editted files ?

Post by Heiner Stev » Thu, 30 May 1996 04:00:00


 > Is there a good script to maintain the earliest and latest
 > dated files and delete the others?  As I edit my files, I
 > automatically create a unique backup named with the date and
 > time.  Thanks for any pointers.

 > -rwx-- 1 eric ipusers  893 Apr 19 16:43 ..login.960419.16:43~.gz*  KEEP
 > -rwx-- 1 eric ipusers  890 Apr 20 11:46 ..login.960420.11:46~.gz*  KILL
 > -rwx-- 1 eric ipusers 1151 Apr 20 11:58 ..login.960420.11:58~.gz*  KILL
 > -rwx-- 1 eric ipusers 1158 Apr 20 12:03 ..login.960420.12:03~.gz*  KILL
 > -rwx-- 1 eric ipusers 1193 Apr 20 12:10 ..login.960420.12:10~.gz*  KILL
 > -rwx-- 1 eric ipusers 1193 Apr 22 17:02 ..login.960422.17:02~.gz*  KILL
 > -rwx-- 1 eric ipusers 1196 Apr 26 15:51 ..login.960426.15:51~.gz*  KEEP

    # rmbackups - remove unused backup files
    : ${BackupDir:=`pwd`}

    n=`ls -t "$BackupDir" | wc -l`
    n=`expr ${n:-0} - 1`
    [ $n -gt 1 ] &&
        ls -t "$BackupDir" | sed -n "2,${n}p" | xargs rm

Be careful - this example actually deletes files. It does not
care for the name of the backup file, only for the time of the
last modification ("ls -t").

Heiner
--
     -------------------------------------------------------------

   / BinTec Communications      / mine, not BinTec's --       /
  / Willstaetter Str. 30 ------- ...even if they should be ;-)/

------------------------------------------------------------

 
 
 

? culling multiple backups of small editted files ?

Post by Brian S Hil » Fri, 31 May 1996 04:00:00


: Is there a good script to maintain the earliest and latest dated files and
: delete the others?  As I edit my files, I automatically create
: a unique backup named with the date and time.  Thanks for any pointers.
: -rwx-- 1 eric ipusers  893 Apr 19 16:43 ..login.960419.16:43~.gz*  KEEP
: -rwx-- 1 eric ipusers  890 Apr 20 11:46 ..login.960420.11:46~.gz*  KILL
: -rwx-- 1 eric ipusers 1151 Apr 20 11:58 ..login.960420.11:58~.gz*  KILL
: -rwx-- 1 eric ipusers 1158 Apr 20 12:03 ..login.960420.12:03~.gz*  KILL
: -rwx-- 1 eric ipusers 1193 Apr 20 12:10 ..login.960420.12:10~.gz*  KILL
: -rwx-- 1 eric ipusers 1193 Apr 22 17:02 ..login.960422.17:02~.gz*  KILL
: -rwx-- 1 eric ipusers 1196 Apr 26 15:51 ..login.960426.15:51~.gz*  KEEP

This will print out the "rm" commands to use, for the case of the
specific files labelled above. Enclose in an "eval" builtin to then
execute these commands (make sure to backslash characters having
significance to the shell, like the dollar sign below). The fundamental
idea is demonstrated below and making into a robust script is "left as
an exercise to the student."

ls -t ..login.9604* | sed -n '
1d
$d
s/^/rm -f /p'

-Brian
--
   ,---.     ,---.     ,---.     ,---.     ,---.     ,---.     ,---.  
  /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \  

__,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.__

 
 
 

? culling multiple backups of small editted files ?

Post by Geoff Cla » Fri, 31 May 1996 04:00:00



> > Is there a good script to maintain the earliest and latest
> > dated files and delete the others?
>    # rmbackups - remove unused backup files
>    : ${BackupDir:=`pwd`}
>    n=`ls -t "$BackupDir" | wc -l`
>    n=`expr ${n:-0} - 1`
>    [ $n -gt 1 ] &&
>    ls -t "$BackupDir" | sed -n "2,${n}p" | xargs rm

If $BackupDir is not the current directory, this gets a list of files
that are in $BackupDir but tries to remove them from the current
directory.  Also, the initial wc and expr can easily be avoided.

    cd ${BackupDir:-.} &&
    ls -t | sed -e '1d' -e '$d' | xargs rm -f delete_me

(Pet peeve: why isn't there an option to xargs to tell it not to execute
the command if it receives no input?)
--

UniSoft Limited, London, England.

 
 
 

? culling multiple backups of small editted files ?

Post by Andreas Schw » Thu, 06 Jun 1996 04:00:00


|> (Pet peeve: why isn't there an option to xargs to tell it not to execute
|> the command if it receives no input?)

Use GNU xargs (-r --no-run-if-empty).
--
Andreas Schwab                                      "And now for something

 
 
 

1. Please help cull unneeded W95 files.

I've got Linux on my laptop, and right now my 800 mb hd is split
equally between Linux and Dos/Windows95.  I really only use the
Dos side for keeping my grades in Excel, and so would like to get
rid of everything else on the Dos side -- make it as small as
possible, and repartition to give the Linux side at least 600 MB.

If anyone has a list of files and/or directories that I can delete
wholesale, I'd be most grateful.  I'm a long-time unix guy but don't
know much at all about the world of Dog Windows.  

Thanks very much!
Matt
--
Matt A. Wood                            Associate Professor

Tel: (407) 768-8000 (x7207)             Florida Institute of Technology
Fax: (407) 984-8461                     Melbourne, FL  32901-6988
WWW: http://pss.fit.edu/wood.html                                      O-

2. [Fwd: Printing with awk?]

3. help on vi to view/edit multiple files

4. Daewoo Monitor Problem?

5. editing and saving multiple files

6. XFree86 and "xvidtune"

7. how to edit multiple source files?

8. CASE Tools for Linux?

9. multiple edits (was: Open Files - Can they be detected?)

10. HP JetDirect not printing from SCO when multiples smalls files sent

11. Solution: multiple Apache log files, multiple args to env=, multiple conditions to CustomLog directive

12. how do i concatenate multiple files then split them into multiple files

13. how backup multiple filesystems onto 1 tape using backup by i-node ?