View Full Version : [ubuntu] Empty directory ecept certain files

January 10th, 2011, 09:13 PM
So I have this script in my cronjob to make a .tar.gz every hour

tar czf /home/rmb938/worldbackup/world_"$(date)".tar.gz /home/rmb938/server/world/ Now eventually that folder were its saving the tar will get to big and I would like to delete the files in the folder.

How would I go about emptying the folder but keep all the files that contain "yesterdays" date.

January 10th, 2011, 10:28 PM
you can use 'find' to find the files, and rm to remove them

here's an example: http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/

January 10th, 2011, 10:30 PM
oh wow that works. Thanks :)