Gzip Many Logfiles in One
Time
My Script actually list the files consuming large disk
it need compress the log files..
Here are the files:
Hello_2009_10_22.log
Hello_2009_10_23.log.gz
Hello_2009_10_24.log.gz
Hello_2009_10_22.log
Hello_2009_11_26.log
Hello_2009_10_22.log.
In the above I have to gzip all files that are not
compressed in one cmd..
Solutions:
Code:
gzip -9 Hello_2009*By default it won't compress files
which already have a .gz extension
Code:
gzip: Hello_2009_10_23.log.gz already has .gz suffix
-- unchangedYou can get rid of the errors by:
Code:
gzip -9 Hello_2009* 2> /dev/null
or
Why not find ?
Code:
$ find . -iname "Hello*"
./Hello_2009_10_22.log.
./Hello_2009_11_26.log
./Hello_2009_10_24.log.gz
./Hello_2009_10_23.log.gz
./Hello_2009_10_22.log( or )
Code:
find . -iname "Hello*" -not -iname "*.gz"
./Hello_2009_10_22.log.
./Hello_2009_11_26.log
./Hello_2009_10_22.logAnd then execute gzip on it as
Code:
find . -iname "Hello*" -not -iname "*.gz" -exec gzip
{} \;
Have a Unix Problem
Unix
Forum - Do you have a UNIX Question?
Unix Books :-
UNIX Programming,
Certification, System Administration, Performance Tuning Reference Books
Return to : - Unix
System Administration Hints and Tips
(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies.
The site www.gotothings.com is in no way affiliated with
or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.
|