If you are running a Linux Distribution, a Mac OS X or other Unix-like operating system, your system certainly has the tar program on it already.You can see the tar manual by typing '$man tar'.
To unpack a tarball, use
$ tar xvf <tarball>
The x stands for extract.
The v stands for verbose output
The f stands for filename of archive
To uncompress a gzip compressed tar, use option z in addition to the above
$ tar xvzf <tarball>
The z stands for uncompress a gzip archive
To uncompress a bzip2 compressed tar, use option j instead of z
$ tar xvjf <tarball>
To create a tar archive,use
$ tar cvf <tarball name> <file/directory to be archived>
The c stands for create archive
The v stands for verbose list files which have been processed
The f stands for filename of archive
To create a compressed archive, use
$ tar cvzf <tarball name> <file/directory to be archived>
This creates a gzip compressed archive
In order to create a bzip2 compressed archive, use option j.
$ tar cvjf <tarball name> <file/directory to be archived>
In order to add a file or directory to an existing archive, use the following:
$ tar rvf <tarball name> <file/directory to be added>
** however, you cannot add a file or directory to a compressed archive.
$ tar tvf <tarball>
Similar to above two cases, for a compressed archive you can use the options 'j' or 'z' depending on the type of compression.
tar xvf <tarball> <path to file>
Instead of a file, if we specify a directory, the directory will be extracted from the path.
We can also specify multiple files/directories for extraction.
Wildcards can also be used for extracting files matching a specific pattern
Reference: Open Hatch Tar quick reference
Unpacking a tarball
To unpack a tarball, use
$ tar xvf <tarball>
The x stands for extract.
The v stands for verbose output
The f stands for filename of archive
To uncompress a gzip compressed tar, use option z in addition to the above
$ tar xvzf <tarball>
The z stands for uncompress a gzip archive
To uncompress a bzip2 compressed tar, use option j instead of z
$ tar xvjf <tarball>
Creating a tarball
To create a tar archive,use
$ tar cvf <tarball name> <file/directory to be archived>
The c stands for create archive
The v stands for verbose list files which have been processed
The f stands for filename of archive
To create a compressed archive, use
$ tar cvzf <tarball name> <file/directory to be archived>
This creates a gzip compressed archive
In order to create a bzip2 compressed archive, use option j.
$ tar cvjf <tarball name> <file/directory to be archived>
In order to add a file or directory to an existing archive, use the following:
$ tar rvf <tarball name> <file/directory to be added>
** however, you cannot add a file or directory to a compressed archive.
Listing an archive
The tar content can be viewed before extracting by using the following command$ tar tvf <tarball>
Similar to above two cases, for a compressed archive you can use the options 'j' or 'z' depending on the type of compression.
Extract a single file
To extract a single file from the archive, you can specify the name of the file at the end of extract commandtar xvf <tarball> <path to file>
Instead of a file, if we specify a directory, the directory will be extracted from the path.
We can also specify multiple files/directories for extraction.
Wildcards can also be used for extracting files matching a specific pattern
Reference: Open Hatch Tar quick reference
No comments :
Post a Comment