1834779 Members
3181 Online
110070 Solutions
New Discussion

Compress by date

 
SOLVED
Go to solution
Jason Heisley
Occasional Advisor

Compress by date

I have searched man pages and the forms but I do not understand how I can compress a large number of files by date.
I would like to compress all files older than 9 months.

Help please:)
7 REPLIES 7
Michael Tully
Honored Contributor
Solution

Re: Compress by date

Hi,

You could try this. Be aware that you don't want to do all filesystems. Change the number of days to your value.

# /usr/bin/find /myfilesystem -mtime +days | xargs /usr/contrib/bin/gzip

HTH
~Michael~
Anyone for a Mutiny ?
steven Burgess_2
Honored Contributor

Re: Compress by date

Hi

find / -type f -mtime +279 -name '*.dat' -exec gzip {} \;

That will find all regular files (-type f) older than 279 days (-mtime +279) that end with '.dat' (-name '*.dat') and then call gzip on that file.

Regards

Steve
take your time and think things through
steven Burgess_2
Honored Contributor

Re: Compress by date

Hi

yeah - sorry, you certainly don't want to do this from /

Steve
take your time and think things through
steven Burgess_2
Honored Contributor

Re: Compress by date

Jason

Have attached a little word doc that I use for reminders

Steve
take your time and think things through
S.K. Chan
Honored Contributor

Re: Compress by date

I have another example, you may/may-not like it.. (assuming current date)

# cd /tmp
# touch 200109010001 ref
==> Create an empty file called "ref" dated Sept 1, 2000.
2001=yr
09=month
01=day
00=hour
01=minute
# cd /data
# find . -newer /tmp/ref -exec gzip {} \;
==> Compress all files that are newer than the timestamp on file /tmp/ref.
S.K. Chan
Honored Contributor

Re: Compress by date

sorry .. Sept 1, 2001 ..
John Carr_2
Honored Contributor

Re: Compress by date

Hi

you can also use the command compress as well as gzip

find /myfilesystem -mtime +279 -exec compress {} \;

John.