Tar: Difference between revisions
Line 19: | Line 19: | ||
== Examples: == | == Examples: == | ||
Create a new archive: | '''Create a new archive:''' | ||
<code>tar -czvf mytar.tgz *</code> creates a tarball named “mytar.tar.gz”, and archives all files in the current directory into it. | <code>tar -czvf mytar.tgz *</code> - creates a tarball named “mytar.tar.gz”, and archives all files in the current directory into it. | ||
'''Extract from an archive:''' | |||
List the contents of a tarball: | <code>tar -xzvf mytar.tgz </code> - Extracts all files in the tarball into the current directory (You can specify a file name at the end to extract just that file.) | ||
'''List the contents of a tarball:''' | |||
<code>tar -tzvf mytar.tgz</code> | <code>tar -tzvf mytar.tgz</code> |
Revision as of 16:28, 24 January 2017
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
-x extract files from an archive
Examples:
Create a new archive:
tar -czvf mytar.tgz *
- creates a tarball named “mytar.tar.gz”, and archives all files in the current directory into it.
Extract from an archive:
tar -xzvf mytar.tgz
- Extracts all files in the tarball into the current directory (You can specify a file name at the end to extract just that file.)
List the contents of a tarball:
tar -tzvf mytar.tgz