utkarsh tyagi utkarsh tyagi - 1 year ago 93
Bash Question

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download