Pack or unpack .tar or tar.gz

===================================================================

Als voorbeeld, om wordpress te compressen met tar en gzip > tar.gz

tar -cvf wp_2.0.7_bu.tar wp
gzip wp_2.0.7_bu.tar

$ ls -l *.gz
-rw-r–r– 1 myhood-nl customers 1551971 2007-02-02 13:56 wp_2.0.7_bu.tar.gz

-[to extract WP into server directory:]——————————-
Place the package in a directory parallel to your current wordpress directory (like “uploads,” for example). Then, unzip it using: gunzip -c wordpress-2.2.1.tar.gz | tar -xf – or by using: tar -xzvf latest.tar.gz
The WordPress package will be extracted into a folder called wordpress.

===================================================================

Compressed UNIX tar archives (typically tar.gz or .tgz extensions) can be extracted in a single command. This is faster and works with less disk space available.

To extract the compressed tar archive target.tar.gz into the current working directory with:

gzip -dc target.tar.gz | tar xf –

If the file was compressed with bzip2 (i.e., .tar.bz2), you can substitute the bzip2 command for gzip.

If the archive was compressed with the UNIX compress command (archive ending in .Z) you can use:

zcat target.tar.Z | tar xf –

===================================================================

More found at a wiki page:
http://en.wikipedia.org/wiki/Tar_(file_format)

On the command line

* To pack tar files, use the following commands:
o for an uncompressed tar file:

tar -cf packed_files.tar file_to_pack1 file_to_pack2 …

o to pack and compress (one step at a time):

tar -cf packed_files.tar file_to_pack1 file_to_pack2 …
gzip packed_files.tar

o to pack and compress all at once:

tar -cf – file_to_pack1 file_to_pack2 … | gzip -c > packed_files.tar.gz

o to create a tar from a directory and its subdirectories:

tar -cvf packed_files.tar dir_to_pack

* To unpack tar files, use the following commands:
o for an uncompressed tar file:

tar -xvf file_to_unpack.tar

o to decompress and unpack one step at a time:

gunzip packed_files.tar.gz
tar -xf packed_files.tar

o to decompress and unpack all at once:

gunzip -c packed_files.tar.gz | tar -xf –

* To list the contents of a tar file, use the following command:

tar -tvf file_to_list.tar

To use bzip2 instead of gzip, simply replace the commands above with bzip2 where gzip is used and bunzip2 where gunzip is used.

===================================================================

Leave a Reply

Your email address will not be published. Required fields are marked *