utkarsh tyagi
utkarsh tyagi

Reputation: 655

Tar or gzip the find result on AIX using single command

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

Answers (2)

ph0nq
ph0nq

Reputation: 37

why not simply use
find /dir/subdir/ -type f -mtime +14 -exec tar -cvf foo.tar {} \;

Upvotes: 0

GMichael
GMichael

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

Related Questions