Friday, August 12, 2005

Need help to tar files in a directory older(creation date) than 45 days old

eed help to tar files in a directory older(creation date) than 45 days old
All 4 messages in topic - view as tree

Need help to tar files in a directory older(creation date) than 45 days
old. say there is 1000 files in the directory and only 300 of them are
older than 45 days old..i want to have it archive(tar) only the 300
older files and leave the rest. Filename structure is:

filename.dat.Z (they have been compressed already

I just cant seem to get anything I try to work correctly please help!

I was trying combinations of find and tar wasn't working right.

d

> I was trying combinations of find and tar wasn't working right.

Linux:
find . -type f -mtime +45 -print0 | xargs -0 tar cf ../file.tar

Solaris, HPUX11.11:
find . -type f -mtime +45 -exec tar cf ../file.tar {} +

If none of the above works, and file names do not have spaces:
find . -type f -mtime +45 -print | xargs tar cf ../file.tar

> find . -type f -mtime +45 -print0 | xargs -0 tar cf ../file.tar
> find . -type f -mtime +45 -exec tar cf ../file.tar {} +
> find . -type f -mtime +45 -print | xargs tar cf ../file.tar

Wouldn't the above methods overwrite "../file.tar" each time the max #
of arguments to 'tar' is reached (first and third cases, due to
repeating the tar invocation with a new list of filename arguments), or
for each new file found (second case, one tar invocation per file
found)?

Reply

> Linux:
> find . -type f -mtime +45 -print0 | xargs -0 tar cf ../file.tar

Without xargs:

find . -type f -mtime +45 -print | tar -cf file.tar -T -

0 Comments:

Post a Comment

<< Home