> >>> 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.
> >> 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 -
> Works *ONLY* if you have a version of tar that supports the '-T' option.
Linux will likely use Gnu tar which does.
But as Jim points out elsethread, the find -exec and xargs versions are
dangerous and should not be used.
Probably the best portable answer is to use a two-step process:
first, use find to create either an include or an exclude list, then,
second, call tar with the include or exclude list. Alternatively, use
cpio (which does read stdin) rather than tar.