Reputation: 655
I am trying to write command which can look for the files which are older than 14 days and tar those files, I have tried many things but what happens is they find result give the names of the file and the tar command just writes the name into one files.
Command used:
find /dir/subdir/ -type f -mtime +14 | tar -cvf data.tar -T -
I am not strictly looking for gzip will also do. Operating system is AIX
Upvotes: 1
Views: 2005
Reputation: 37
why not simply use
find /dir/subdir/ -type f -mtime +14 -exec tar -cvf foo.tar {} \;
Upvotes: 0
Reputation: 2776
Please consider the following:
find /dir/subdir/ -type f -mtime +14 > file.list
tar -cvf data.tar -L file.list
You may need to modify the find
call using something like -print0
switch on Linux if your file names contain white space-like symbols.
Upvotes: 3