Operating System - HP-UX
1754119 Members
3462 Online
108811 Solutions
New Discussion юеВ

Re: script needed to compress log files

 
SOLVED
Go to solution
kingkhan
Occasional Advisor

script needed to compress log files

i am having 200 log files in a directory i want to compress the log files which are having size more than 10 mb, help me to have a script
5 REPLIES 5
Pete Randall
Outstanding Contributor

Re: script needed to compress log files

Something like this:

find /log_directory -size +10000000c -exec compress {} \;


Pete

Pete
Solution

Re: script needed to compress log files

assuming directory is /mydir

find /mydir -size +10485760c -exec compress {} \;

Of course if there are files in a sub-directory of mydir of >10MB they would get compressed too with this code, so don't use if you have subdirs containing stuff you don't want compressed.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Dennis Handly
Acclaimed Contributor

Re: script needed to compress log files

Why would you care about the size, just use:
$ gzip !(*.gz)

gzips all that aren't gzipped.
kingkhan
Occasional Advisor

Re: script needed to compress log files

thanks it worked out
kingkhan
Occasional Advisor

Re: script needed to compress log files

find /mydir -size +10485760c -exec compress {} \;

this worked out. as i want to rescue files less than 10 mb. it necessary to check the size