Tar-ring up a directory, only those files that have changed in last 24 hours

Tar-ring up a directory, only those files that have changed in last 24 hours

Post by Larry Quant » Tue, 30 Dec 1997 04:00:00



        I'm using the "find" command to print out a listing of only those files
that have changed on my system in the last 24 hours, then tarring them up
and ftping them over to another machine for safekeeping.  So far, the find
command syntax I use is this:

find . -mtime 1 -print > thefilelisting

All well and good.  I then use the list of files as the input for the tar
command.  Unfortunately, when you add a file to a directory, the timestamp
of the directory changes as well, and the find command will list that
directory on a line of its own, along with those files within it that meet
the criteria.  This wouldn't be a problem, except that when tar is given a
subdirectory as input, it automatically recurses through that subdirectory,
and tars up all of the files in it, recent or not. Thus, whenever a file is
added to a directory, all of the files in it are tarred up, even if they
don't need to be.  Does anyone know of an elegant way to tar up only those
files that have been modified in the last 24 hours?  Thanks.  I'm using
UnixWare 2.1, if that makes any difference.

 
 
 

Tar-ring up a directory, only those files that have changed in last 24 hours

Post by Tom Barro » Tue, 30 Dec 1997 04:00:00



>         I'm using the "find" command to print out a listing of only those files
> that have changed on my system in the last 24 hours, then tarring them up
> ...
> find . -mtime 1 -print > thefilelisting

> don't need to be.  Does anyone know of an elegant way to tar up only those
> files that have been modified in the last 24 hours?  Thanks.  I'm using
> UnixWare 2.1, if that makes any difference.

Should be the same for all Unices with the standard find command line
syntax:

   find . -mtime 1 -type f -print > ...

This finds only regular files (not directories, character- or
block-special files, etc.).  It will recurse its way down through
subdirectories, but subdirectory names won't appear in the output of the
find command.
--
Tom


 
 
 

Tar-ring up a directory, only those files that have changed in last 24 hours

Post by Roelof den Dekke » Wed, 31 Dec 1997 04:00:00


If I understood your problem well you could try to expand your find command
:

find . mtime 1   ! -type d    -print .... etc

this way the find command will _not_ list the names of the (sub)dirs.



Quote:

>    I'm using the "find" command to print out a listing of only those files
> that have changed on my system in the last 24 hours, then tarring them up
> and ftping them over to another machine for safekeeping.  So far, the
find
> command syntax I use is this:

> find . -mtime 1 -print > thefilelisting

> All well and good.  I then use the list of files as the input for the tar
> command.  Unfortunately, when you add a file to a directory, the
timestamp
> of the directory changes as well, and the find command will list that
> directory on a line of its own, along with those files within it that
meet
> the criteria.  This wouldn't be a problem, except that when tar is given
a
> subdirectory as input, it automatically recurses through that
subdirectory,
> and tars up all of the files in it, recent or not. Thus, whenever a file
is
> added to a directory, all of the files in it are tarred up, even if they
> don't need to be.  Does anyone know of an elegant way to tar up only
those
> files that have been modified in the last 24 hours?  Thanks.  I'm using
> UnixWare 2.1, if that makes any difference.