1833883 Members
1803 Online
110063 Solutions
New Discussion

Re: gzip command

 
SOLVED
Go to solution
Dan Maul
Trusted Contributor

gzip command

I have a dir full of debug logs and I would like to gzip the entire dir.
Can someone Please help me with the commands.
My unix skills are limited. Please forgive.
I always keep a supply of stimulant handy in case I see a snake--which I also keep handy.
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: gzip command

It really couldn't be simpler:

cd mydir
gzip *.log

That would gzip all the files with ending with .log and replace them with .log.gz.

man gzip for details.


If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: gzip command

Hi:

# gzip -rv /logdir

Regards!

...JRF...
Dan Maul
Trusted Contributor

Re: gzip command

Thanks Clay!

You were on the money!

I always keep a supply of stimulant handy in case I see a snake--which I also keep handy.
blal
Frequent Advisor

Re: gzip command

Hi

You can use the following.

ls -al |grep -v ^d |awk '{print $9}'|while read a ;do gzip $a;echo "$a zipped" ;done


(before executing just make sure ls -al |grep ^d is displaying all the file names which you need to be zipped other than sub directory names )

explanation.

ls -al |grep -v ^d --> will extact all the files other than directories(I have taken in to consideration that you may have sub dir in side that dir)

awk '{print $9}' -->will extract the ninth field from the ls -al out put which will be the file names.

then the file names are parsed into a while ,do ,done loop.

this will zip all the files other than directories .

if u have some specific file patter then
for example *.log

ls *.log |while read a ;do gzip $a;echo "$a zipped" ;done
will do .

regds,
baiju
Live and let live.
Rory R Hammond
Trusted Contributor

Re: gzip command



Asume that your log files are in:
/mnt/log/archive

gzip -r /mnt/log/archive

Will gzip all the files.
This works like the compressdir command

Assume that you have directory tree that you want to
compress up and leave in place:

|-bin----------|-runhpterm2---
|-hithere-----
|-test2-------
|
| |-OO081701.DBF-
| |-OO081801.DBF-
User-----| |-OO081901.DBF-
| |-OO082001.DBF-
| |-OO082101.DBF-
|-data---------|-OO082201.DBF-
|-OO082301.DBF-
|-OO082401.DBF-
|-OO100201.DBF-



gzip -r /home/User

will do files in all the directories.

Ror
There are a 100 ways to do things and 97 of them are right
Tim D Fulford
Honored Contributor

Re: gzip command

Hi

Not related to your problem as that has been amply answered above. But when transporting the files (I assume you will e-mail these files somewhere/to someone) remember if using FTP to use BINARY transfer, otherwise those files will end up corrupted!!

Tim
-