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
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.
Or if you don't have GNU-tar and don't want to install it:
tar -cvf - /directory/* | gzip > file.tar.gz
/Marcus
tar -cvf - directory | gzip > file.tar.gz
$ tar cvf - /directory/* | gzip > file.tar.gz
Why are you using the wildcard (*)?
--
Stefaan
--
"What is stated clearly conceives easily." -- Inspired sales droid
an error appear
tar:/directory/dir1: Is a directory
Thanks
"Marcus" <ca...@home.se> wrote in message news:3F4A3F7F...@home.se...
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
> 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