Operating System - HP-UX
1830870 Members
2215 Online
110017 Solutions
New Discussion

Need zip command tips , thanks

 
SOLVED
Go to solution
violin_1
Advisor

Need zip command tips , thanks

DEAR ALL Fellow,

Need helps,

If i got the a file : abc.txt , and i also need to zip it

[gbm5:/] #ll abc*
-rw-rw-rw- 1 root sys 27 Oct 8 11:57 abc.txt


[gbm5:/] #gzip abc.txt
[gbm5:/] #ll abc*
-rw-rw-rw- 1 root sys 50 Oct 8 11:57 abc.txt.gz
[gbm5:/] #

How could I keep both files :
abc.txt and abc.txt.gz

like this:
[gbm5:/] #ll abc*
-rw-rw-rw- 1 root sys 27 Oct 8 11:57 abc.txt
-rw-rw-rw- 1 root sys 50 Oct 8 11:57 abc.txt.gz
[gbm5:/] #

Does gzip optional make it?
Thanks for your tips,

Violin.
violin@gbmgroup.com.cn
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: Need zip command tips , thanks

In UNIX the most common thing to do is to gzip a tarball. You first usr tar to make an archive and then gzip the tar file.

tar cvf /tmp/myfiles.tar abc.txt def.txt ghi.dat
gzip /tmp/myfiles.tar


To reverse the process you:
gunzip myfiles.tar.gz
tar xvf myfiles.tar
If it ain't broke, I can fix that.
Victor Fridyev
Honored Contributor
Solution

Re: Need zip command tips , thanks

Hi,

gzip -c abc.txt > abc.txt.gz

HTH
Entities are not to be multiplied beyond necessity - RTFM
Arunvijai_4
Honored Contributor

Re: Need zip command tips , thanks

You can use "jar" that comes with HP Java.

# /opt/java1.4/bin/jar -cvf fork.zip fork.c
added manifest
adding: fork.c(in = 333) (out= 208)(deflated 37%)
# ls fork.c fork.zip
fork.c fork.zip

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Need zip command tips , thanks

The Gnu tar has an -z option for compressing

tar -cvfz abc.txt

It will give you both the original file plus the compressed file.
Vibhor Kumar Agarwal
Tim D Fulford
Honored Contributor

Re: Need zip command tips , thanks

cat abc.txt | gzip - > abc.txt.gz

Tim
-