Move old file to other directory
I have a directory , there are many files created in it , I want to use the command to move the files which elder than 30 days and gzip it and then move it to /tmp , and then remove those files , I tried use below command but not work , can advise how can I do it ? thx
find ~path -type f -mtime 30 -exec tar -zcvf - {} --remove-files > /tmp/oldfile.tgz \; |
Your command is trying to run the tar program once for each file found.
You can use find to generate the list of files. find ~path -type f -mtime +30 -print0 | xargs -0 tar -C ~path zcvf /tmp/oldfile.tgz - For a very long list of files, it may be better to save the list of files and use that or use a limiting option of xargs. |
All times are GMT -5. The time now is 09:38 PM. |