Wednesday, August 17, 2005

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

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

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.

Reply


Michael Tosch Aug 11, 4:45 pm show options
N
> 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

--
Michael Tosch @ hp : com

Reply


Jim Aug 11, 4:56 pm show options

> 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


Michael Heiming Aug 11, 5:16 pm show options

> 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 -

Seems we are missing something like uuox award? ;-)

[..]

0 Comments:

Post a Comment

<< Home