Thursday, March 12, 2015

Linux Tips: find and tar





a.  Find files more than 60 days in the current location and tar the files

                     find . -type f -mtime +60 | xargs tar czf logs_olderthan60days.tar.gz

b. Find files more than 60 days in a certain path, and tar the files

                      find /project/utils/cal -type f -mtime +60 | xargs tar czf logs_olderthan60days.tar.gz

c.  Find files in nohup mode

                      nohup find . -type f -mtime +60 | xargs tar czf logs_olderthan60days.tar.gz &

d. Find files, but exclude certain folders

             find . -type f -mtime +60 | xargs tar czf logs_olderthan60days.tar.gz --exclude="folder1"

No comments:

Post a Comment