how to compress files using gzip

  • Follow


How do I compress multiple files to one archive file using a gzip
command ?
0
Reply danwgrace (24) 12/31/2008 4:00:10 PM

On Wed, 31 Dec 2008 08:00:10 -0800, Daniel wrote:

> How do I compress multiple files to one archive file using a gzip
> command ?

man gzip
man tar


-- 
"Ubuntu" -- an African word, meaning "Slackware is too hard for me".
The Usenet Improvement Project: http://improve-usenet.org
Ahhhhhhh!:  http://brandybuck.site40.net/pics/relieve.jpg
0
Reply youmustbejoking2 (560) 12/31/2008 4:34:18 PM


Wed, 31 Dec 2008 08:00:10 -0800, Daniel did cat :

> How do I compress multiple files to one archive file using a gzip
> command ?

 if you have GNU tar
$ tar cpzvf myarch.tgz file1[ file2]*

 else (or if in a compound script, go classical):
$ tar cpvf - file1[ file2]* | gzip -c - > myarch.tar.gz

 there are other variants but I tried to put the most didactic ones ;-)
0
Reply l0k1 (291) 12/31/2008 5:08:17 PM

In article <7bb8072d-5914-4292-93c0-178c2e7e0beb@d36g2000prf.googlegroups.com>,
Daniel  <danwgrace@gmail.com> wrote:
> How do I compress multiple files to one archive file using a gzip
> command ?

You can't (normally) using just gzip.  Add in tar or cpio and it's one
file, which you can gzip.

-- 
-eben         QebWenE01R@vTerYizUonI.nOetP          royalty.mine.nu:81

"windows seems to have stupidity buil[t] into it." -- sobriquet on a.o.l.
0
Reply ebenZEROONE (419) 12/31/2008 6:17:16 PM

Daniel wrote:

> How do I compress multiple files to one archive file using a gzip
> command ?

The man pages give exact examples that cover this, for reference now and
in the future.  man gzip as well as man tar will help.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
0
Reply tim199 (261) 12/31/2008 6:23:21 PM

Daniel <danwgrace@gmail.com> wrote:

> How do I compress multiple files to one archive file using a gzip
> command ?

gzip just compresses one file, it doesn't create archives. Use tar, cpio
or similar to create an archive and compress that using gzip.



   Florian
-- 
<http://www.florian-diesch.de/>
-----------------------------------------------------------------------
**  Hi! I'm a signature virus! Copy me into your signature, please!  **
-----------------------------------------------------------------------
0
Reply diesch (335) 12/31/2008 6:34:27 PM

Daniel <danwgrace@gmail.com> wrote:
> How do I compress multiple files to one archive file using a gzip
> command ?

man tar

tar cvvzf archive_name.tar.gz file1 file2 file3 file4 ...

More detailed information would result in better advice.

For instance, if you wanted to archive all the mp3 files
in a directory:

tar cvvzf archive_name.tar.gz *.mp3

Sid

-- 
My newsfilter kills more than half the posts to these groups,
including replies to any name in my killfile. So if I don't
respond to a reply it is because I didn't see it. 
Thou shalt not suffer a troll to speak in thine presence.
0
Reply nospam59 (9950) 12/31/2008 6:52:18 PM

ObTrollAlert: Yes, I know ''Sidney'' is a troll.  But there's still a
point to be made.

On 2008-12-31, Sidney Lambe <nospam@nospam.invalid> wrote:
> For instance, if you wanted to archive all the mp3 files
> in a directory:
>
> tar cvvzf archive_name.tar.gz *.mp3

This is a stylistic point, but typically if you create a tar archive (or
tarball) that you might share with others, you create a top-level
directory, so that when the other person extracts the tarball it doesn't
pollute whatever directory he happens to be in.

So for the above example you might do

cd ~/dir/above/mp3s/
tar cvzf ~/mymp3s.tar.gz mymp3s/*.mp3

On extraction, tar will create a new directory mymp3s/ and put the mp3
files there.  (Of course if the user already has a mymp3s directory
he'll pollute that, which is why I usually do

tar tvzf mymp3s.tar.gz

to see if it has a top-level directory or not.)

You should (almost) *never* do

tar cvzf filename.tar.gz /etc/ /...

or any file spec with a leading / , because on extraction tar will
attempt to put the new files there!  As nonroot it might just simply
fail; as root it might clobber important files.  (Some versions of tar
warn you of this and/or strip the leading / when creating the archive.)

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information

0
Reply kkeller-usenet (1289) 12/31/2008 10:21:05 PM

7 Replies
35 Views

(page loaded in 0.14 seconds)


Reply: