How can i zip a file
Hai,
I have written a script in perl which writes some data to a file. As the data written in that file is more, and the size of that file is more, I want to zip the file after the data being written to it. Please help me to do this. Thanks, Prakash. |
Quote:
example. zip -r var.zip var/* |
Hi,
Thanks for your reply. I tried zip -r new.zip /tmp/new.csv and also zip -r /tmp/new.zip /tmp/new.csv but in both instances its saying that there is a syntax error. Can you please post me the complete syntax. Thanks, Prakash. |
|
Bzip and bzip are more often used to compress files in Linux and Unix.
|
Hi,
I am not trying to add any thing to an existing zip file. I just want to decrease the size of the file(compress) by converting it to a zip file. Please help me in doing so. Thanks, Prakash. |
Why don't you just bzip or gzip it then, as jschiwal suggested? Read the man pages for bzip2 and gzip for more info on how to use those.
|
Hai,
Thanks for your reply. I just converted a tar file for that file which decreases its size for almost 10%. My problem is solved. Thanks, Prakash. |
Tar has an option (-z) for gzip and (-j) for bzip. If you only have a single file, you can use gzip & bzip2 on there own. For a single file, you can also expand them using zcat (gzip files) and bzcat (bzip2). This would allow you to do things like grep for a pattern inside a compressed file:
example: zcat /proc/config.gz | grep NLS |
Thanks for your reply. I will have a look at it.
Prakash. |
in general if you add -z to tar you get a .tar.gz file that is quite quick to compress and has a reasonable compression,
if you use -j you get .tar.bz2 that is slower to compress but is a better compression level |
There are literally dozens (if not hundreds) of perl modules to deal with compressed files on any imaginable format. Since your script is written in perl, I think that it would make more sense to use one of these modules.
|
All times are GMT -5. The time now is 09:30 PM. |