Tar: Difference between revisions

From Psygen Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


== Flags ==
== Flags ==
    '''-z''' use gzip to compress/read the resulting tarball
 
   
'''-z''' use gzip to compress/read the resulting tarball
    '''-j''' use bzip2 to compress/read the tarball
 
   
'''-j''' use bzip2 to compress/read the tarball
    '''-c''' create a new archive.
 
   
'''-c''' create a new archive.
    '''-v''' verbose. tar will list all the files it's adding to the archive.
 
   
'''-v''' verbose. tar will list all the files it's adding to the archive.
    '''-f''' the result should be saved into a file (as opposed to being stored on a tape)
 
   
'''-f''' the result should be saved into a file (as opposed to being stored on a tape)
    '''-t''' list the contents of an archive
 
'''-t''' list the contents of an archive
      
      
== Examples: ==
== Examples: ==
   
 
Create a new archive:
Create a new archive:
   
<code>tar -zvfc mytar.tgz *</code>  creates a tarball named “mytar.tar.gz”, and archives all files in the current directory into it.


<code>tar -zvfc mytar.tgz *</code>  creates a tarball named “mytar.tar.gz”, and archives all files in the current directory into it.


Extract from an archive:
Extract from an archive:
   
<code>tar -zvfx mytar.tgz </code>  Extracts all files in the tarball into the current directory.


       
<code>tar -zvfx mytar.tgz </code>  Extracts all files in the tarball into the current directory.
 
List the contents of a tarball:
List the contents of a tarball:
   
 
<code>tar -zvft mytar.tgz</code>
<code>tar -zvft mytar.tgz</code>


== References ==
== References ==

Revision as of 02:55, 21 December 2016

creates an archive (Commonly called a tarball. 'tar' is short for 'tape archive')

Flags

-z use gzip to compress/read the resulting tarball

-j use bzip2 to compress/read the tarball

-c create a new archive.

-v verbose. tar will list all the files it's adding to the archive.

-f the result should be saved into a file (as opposed to being stored on a tape)

-t list the contents of an archive

Examples:

Create a new archive:

tar -zvfc mytar.tgz * creates a tarball named “mytar.tar.gz”, and archives all files in the current directory into it.

Extract from an archive:

tar -zvfx mytar.tgz Extracts all files in the tarball into the current directory.

List the contents of a tarball:

tar -zvft mytar.tgz


References

  1. tar man page
  2. Ultimate Tar Command Tutorial