Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Obviously, there are a lot of web pages on TAR out there. However, I have not been able to find a suitable Google query to determine if what I want is even possible.

I have found items such as: http://stackoverflow.com/questions/848293/shell-script-get-all-files-modified-after-date but this is set to archive files newer than a certain date not older than a certain date.

Long story short, I have several automation tools that generate data files and log files every 5 minutes. The data files are named using php's md5 function so they are a 32 char string. The log files vary in their naming convention but generally include the date in the name.

I'd like to use tar to archive and compress these data files and logs (separate archives for each) based on the creation or last modified date - i.e. archive any file with a creation date more than a week old. Is this possible and if so, can you please provide the command?

Second, with respect to these files I'm archiving them instead of deleting them because I will (occasionally) wish to look at them again. With files being created every 5 minutes a lot of files get generated. I'd like to extract only the file I'm interested in and not all of them. Is there any easy way to do this?

My intention would be to archive weekly and delete the archives after they reach approx 6 months of age.


share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.