Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creation of .tar.gz file in one step

2,559 views
Skip to first unread message

Javier Villegas

unread,
Aug 25, 2003, 11:50:31 AM8/25/03
to
Hi

I need to create a tar.gz file in one command line

Now I am doing this :

tar -cvf /file.tar /directory/* and then gzip file.tar

I know that it could be made in one step

Thanks in advance

mjt

unread,
Aug 25, 2003, 12:09:10 PM8/25/03
to
Javier Villegas wrote:

The way I do it is to install GNU-tar and

tar -czvf file.tar.gz /directory/*

After getting used to the -z and -j in GNU-tar on Linux, the Sun
implementation of tar drives me nuts.

Marcus

unread,
Aug 25, 2003, 12:55:27 PM8/25/03
to mjt


Or if you don't have GNU-tar and don't want to install it:
tar -cvf - /directory/* | gzip > file.tar.gz

/Marcus


Oscar del Rio

unread,
Aug 25, 2003, 1:47:08 PM8/25/03
to

tar -cvf - directory | gzip > file.tar.gz

Stefaan A Eeckels

unread,
Aug 25, 2003, 12:27:26 PM8/25/03
to

$ tar cvf - /directory/* | gzip > file.tar.gz

Why are you using the wildcard (*)?

--
Stefaan
--
"What is stated clearly conceives easily." -- Inspired sales droid

Javier Villegas

unread,
Aug 25, 2003, 5:01:30 PM8/25/03
to
This (tar -cvf - /directory/* | gzip > file.tar.gz) did not work.

an error appear

tar:/directory/dir1: Is a directory

Thanks


"Marcus" <ca...@home.se> wrote in message news:3F4A3F7F...@home.se...

Logan Shaw

unread,
Aug 25, 2003, 6:34:11 PM8/25/03
to
Javier Villegas wrote:
> tar -cvf /file.tar /directory/* and then gzip file.tar

Part of the power of Unix is that it gives you tools that
you can combine to achieve something new. You can connect
those two tools (tar and gzip) together with a pipe:

tar -cvf - /directory/* | gzip > file.tar.gz

By the way, in most cases, it isn't necessary to put the "*";
if you give a directory, tar will automatically include everything
in it. So you can do this:

tar -cvf - /directory | gzip > file.tar.gz

Also, you will find the tar file easier to extract if you
don't include an absolute pathname in it, i.e. if you don't
begin it with a slash. You can do that like this:

(cd / && tar -cvf - directory) | gzip > file.tar.gz

Hope that helps.

- Logan

Logan Shaw

unread,
Aug 25, 2003, 6:41:53 PM8/25/03
to
Javier Villegas wrote:

> This (tar -cvf - /directory/* | gzip > file.tar.gz) did not work.
>
> an error appear
>
> tar:/directory/dir1: Is a directory

It sounds like you forgot the second dash and typed this:

tar -cvf /directory/* | gzip > file.tar.gz

instead of this:

tar -cvf - /directory/* | gzip > file.tar.gz

Hope that helps.

- Logan

0 new messages