Tar Archive

From KevinWiki

(Difference between revisions)
Jump to: navigation, search
(Create and Split Tar File into Several Files)
Line 34: Line 34:
-
* If only one file needs to be splited, tar with a single source file is still fine but in this case, gzip can be used as well.
+
* If only one file needs to be split, tar with a single source file is still fine but in this case, gzip can be used as well.
*  create archives
*  create archives
<pre>
<pre>
Line 43: Line 43:
$ cat result_files.gz_* | gunzip -c > one_large_file
$ cat result_files.gz_* | gunzip -c > one_large_file
</pre>
</pre>
-
 
=== List Files Inside Tar File ===
=== List Files Inside Tar File ===

Revision as of 03:41, 8 February 2014

Contents

Tar

Tar is both a file format and the programme to handle that file.

Create GZipped Tar File

$ tar -czvf tar_file_name.tar.gz input_file_or_directory_1 input_file_or_directory_2 ...

Extract GZipped Tar File

$ tar -xzvf tar_file_name.tar.gz

To extract file to a specific directory, use this.

$ tar -xzvf tar_file_name.tar.gz -C /directory/destination_directory

Create and Split Tar File into Several Files

  • create archives
$ tar cz large_file_1 large_file_2 | split -b 1024MiB - result_files.tgz_ 
  • uncompress
$ cat result_files.tgz_* | tar xz 
  • This solution avoids the need to use an intermediate large file when (de)compressing.
  • Use the tar -C option to use a different directory for the resulting files.


  • If only one file needs to be split, tar with a single source file is still fine but in this case, gzip can be used as well.
  • create archives
$ gzip -c one_large_file | split -b 1024MiB - result_files.gz_
  • uncompress
$ cat result_files.gz_* | gunzip -c > one_large_file

List Files Inside Tar File

$ tar -tzf tar_file_name.tar.gz

Create GZipped Tar with NOT GNU Tar

$ tar -cvf - input_file_or_directory_1 input_file_or_directory_2 | gzip > tar_file_name.tar.gz

-If gzip is not available, use compress instead.

Extract GZipped Tar with NOT GNU Tar

gunzip -c tar_file_name.tar.gz | tar -xvf -

-If gunzip is not available, user uncompress instead.

Personal tools