Correct syntax for bzip and gnu tar

  • Follow


I have an HPUX  B.11.00 U 9000/800
I have just installed the depots for gnu tar, gzip, and bzip2.

What is the correct syntax to tar up a directory....
To use the gzip and tar in the same command...

gtar -zcvf   backupfile.???   /opt/app/dir .

I dont know what to put for the extension of the gzip file. Another
question... using the . at the end, it this tared relatively, I have seen
others use the -  What is the difference?

I also want to do some testing with bzip2
gtar -jcvf   backupfile.???   /opt/app/dir .

Again, what is the correct syntax?
As well, does gzip or bzip combined with gtar, take up alot of space, does
it have to tar the file first, and if it is tarring a 3 GB file, would it
put that 3GB file into swap before it starts to compress it.


0
Reply LHradowy 10/8/2003 7:10:48 PM

On Wed, 8 Oct 2003 14:10:48 -0500, LHradowy 
  <laura.hradowy@NOSPAM.mts.ca> wrote:
> I have an HPUX  B.11.00 U 9000/800
> I have just installed the depots for gnu tar, gzip, and bzip2.
> 
> What is the correct syntax to tar up a directory....
> To use the gzip and tar in the same command...
> 
> gtar -zcvf   backupfile.???   /opt/app/dir .
> 
> I dont know what to put for the extension of the gzip file. Another
> question... using the . at the end, it this tared relatively, I have seen
> others use the -  What is the difference?
> 
Unix isn't as strict about the use of file extensions as some other 
operatng systems.  Gzipped tar files usually have the extension .tar.gz 
or .tgz, but the program would work the same with no extension.
The - as in "tar -cvf -" refers to standard input or output.

> I also want to do some testing with bzip2
> gtar -jcvf   backupfile.???   /opt/app/dir .
> 
> Again, what is the correct syntax?
tar.bz2 is recommended.

> As well, does gzip or bzip combined with gtar, take up alot of space, does
> it have to tar the file first, and if it is tarring a 3 GB file, would it
> put that 3GB file into swap before it starts to compress it.
> 
If I'm not mistaken it uses a pipe.


-- 
Cheops' Law:
	Nothing ever gets built on schedule or within budget.
0
Reply Bill 10/8/2003 8:52:39 PM


"LHradowy" <laura.hradowy@NOSPAM.mts.ca> writes:

> I have an HPUX  B.11.00 U 9000/800
> I have just installed the depots for gnu tar, gzip, and bzip2.
> 
> What is the correct syntax to tar up a directory....
> To use the gzip and tar in the same command...
> 
> gtar -zcvf   backupfile.???   /opt/app/dir .
> 
> I dont know what to put for the extension of the gzip file. Another
> question... using the . at the end, it this tared relatively, I have seen
> others use the -  What is the difference?

You can put anything.  

By default,  gzip add a  '.gz' extension to  the name of the  files it
compresses, and usually, we call tar archives with a '.tar' extension,
so  when you gzip-compress  a tar  archive, you  end with  a '.tar.gz'
double extension.  When  the file is to be stored  on file system that
don't allow random file names, we may shorten it to '.tgz'.

 gtar -zcvf   backupfile.tar.gz  /opt/app/dir .

So, you create an archive,  compress it, store it to backupfile.tar.gz
and put  in it  two directories (and  contents): /opt/app/dir  AND the
current directory denoted by '.'.

tar may archive  absolute paths, such as /opt/app/dir,  but modern tar
like gtar  don't extract them (unless  the user is root  and a special
option is given). 

The idiom I use is:

    gtar -zcvf   directory-name.tar.gz    directory-name


Archiving  the  current  directory  is  rude for  the  user  who  will
unarchive it:  he will get all  the files you archived  in his current
working  directory.  It's  cleaner if  the archive  contains  just one
directory, at least,  for public distribution ; you  may have specific
private needs.


The '-'  is used in  place of  the archive file  name to have  tar use
stdin or  stdout as source or  destination of the  archive data.  This
allow you to use pipes to filter or transfer the data.

    gtar -zcvf dir.tar.gz ./dir 

is equivalent to:

    gtar -cvf - ./dir | gzip > dir.tar.gz

and

    gtar -zxvf archive.tar.gz

is equivalent to:

    gzip -d < archive.tar.gz | gtar -xvf -


But this allow you to do things like:

  ssh remote.example.com cat /repository/archive.tar.gz | gtar -zxvf - 

or to copy a directory hierarchy when GNU cp is not available:

   tar -C source-dir -cf - . | tar -C destination-dir -xf -


> I also want to do some testing with bzip2
> gtar -jcvf   backupfile.???   /opt/app/dir .
> 
> Again, what is the correct syntax?

When you can use -j instead  of -z, it's the same syntax. Just replace
the '.gz' extension by a '.bz2' (or '.tgz' by '.tz2').


> As well, does gzip or bzip combined with gtar, take up alot of space, does
> it have to tar the file first, and if it is tarring a 3 GB file, would it
> put that 3GB file into swap before it starts to compress it.

No, it does it on the fly, just as if you used pipes.


-- 
__Pascal_Bourguignon__
http://www.informatimago.com/
Do not adjust your mind, there is a fault in reality.
0
Reply Pascal 10/8/2003 8:55:55 PM

"laura_fairhead" <laura_fairhead@INVALID.com> wrote in message
news:slrnbo93ih.avj.laura_fairhead@bell486.bittersweet.org...
> In article <ZiZgb.22495$uz1.33823@news1.mts.net>, LHradowy wrote:
> >I have an HPUX  B.11.00 U 9000/800
> >I have just installed the depots for gnu tar, gzip, and bzip2.
> >
> >What is the correct syntax to tar up a directory....
> >To use the gzip and tar in the same command...
> >
> >gtar -zcvf   backupfile.???   /opt/app/dir .
>
>
> tar cvf - /path/to/directory |gzip >archive.tar.gz
>
> >
> >I dont know what to put for the extension of the gzip file. Another
> >question... using the . at the end, it this tared relatively, I have seen
> >others use the -  What is the difference?
> >
> >I also want to do some testing with bzip2
> >gtar -jcvf   backupfile.???   /opt/app/dir .
>
> Shouldn't that be an 'I' rather than a 'j'? In any case, as with
> the above j/z are just nasty unneccesary shortcuts try;
>
> tar cvf - /path/to/directory |bzip2 >archive.tar.bz
>
> >
> >Again, what is the correct syntax?
> >As well, does gzip or bzip combined with gtar, take up alot of space,
does
> >it have to tar the file first, and if it is tarring a 3 GB file, would it
> >put that 3GB file into swap before it starts to compress it.
>
> I believe that all GNU-tar does is forks a process for the compression
> utility (be it gzip or bzip2) and makes a FIFO between itself and the
> compressor - in exactly the same way things work if you had done it in
> the normal way  (tar |gzip). You can verify that by using ps/top to
> look at the processes while it workz but it can't really work in anyother
> way because creating that huge file and then compressing it like you say
> would be hideously inefficient.
>
> I would be very wary indeed about using GNU-tar because it is not
> standards compliant. I'd rather use the GNU compression gzip (because
> it is defacto standard ) and use the systems' native tar command (and
> not have to worry about interoperability).
>
> byefornow
> l
>

I have tried to "factory standard tar" it does not support files greater
that 2 GB. Yes, the patch does support 2GB, but only up to 8.
So there for the GNU tar was a life saver.


0
Reply LHradowy 10/8/2003 9:47:18 PM

In article <ZiZgb.22495$uz1.33823@news1.mts.net>, LHradowy wrote:
>I have an HPUX  B.11.00 U 9000/800
>I have just installed the depots for gnu tar, gzip, and bzip2.
>
>What is the correct syntax to tar up a directory....
>To use the gzip and tar in the same command...
>
>gtar -zcvf   backupfile.???   /opt/app/dir .


tar cvf - /path/to/directory |gzip >archive.tar.gz

>
>I dont know what to put for the extension of the gzip file. Another
>question... using the . at the end, it this tared relatively, I have seen
>others use the -  What is the difference?
>
>I also want to do some testing with bzip2
>gtar -jcvf   backupfile.???   /opt/app/dir .

Shouldn't that be an 'I' rather than a 'j'? In any case, as with
the above j/z are just nasty unneccesary shortcuts try;

tar cvf - /path/to/directory |bzip2 >archive.tar.bz

>
>Again, what is the correct syntax?
>As well, does gzip or bzip combined with gtar, take up alot of space, does
>it have to tar the file first, and if it is tarring a 3 GB file, would it
>put that 3GB file into swap before it starts to compress it.

I believe that all GNU-tar does is forks a process for the compression
utility (be it gzip or bzip2) and makes a FIFO between itself and the
compressor - in exactly the same way things work if you had done it in
the normal way  (tar |gzip). You can verify that by using ps/top to
look at the processes while it workz but it can't really work in anyother
way because creating that huge file and then compressing it like you say
would be hideously inefficient.

I would be very wary indeed about using GNU-tar because it is not
standards compliant. I'd rather use the GNU compression gzip (because
it is defacto standard ) and use the systems' native tar command (and
not have to worry about interoperability).

byefornow
l

>
>
0
Reply laura_fairhead 10/8/2003 10:23:17 PM

laura_fairhead@INVALID.com (laura_fairhead) writes:
> I would be very wary indeed about using GNU-tar because it is not
> standards compliant. I'd rather use the GNU compression gzip (because
> it is defacto standard ) and use the systems' native tar command (and
> not have to worry about interoperability).

On  the otherhand  gnutar  is so  much  vastly superior  to the  other
slightly  incompatible tars, that  the easiest  solution to  avoid any
interoperatibility with tar  archive is to compile gnu  tar on all the
your systems that lack it, as did the OP.

Since I've been using gtar, I left all my tar troubles to the past.

-- 
__Pascal_Bourguignon__
http://www.informatimago.com/
Do not adjust your mind, there is a fault in reality.
0
Reply Pascal 10/8/2003 10:35:14 PM

5 Replies
536 Views

(page loaded in 0.159 seconds)

Similiar Articles:













7/23/2012 6:26:31 AM


Reply: