Tar: Difference between revisions
From Leo's Notes
This page was last edited on 1 September 2019, at 01:37.
compression |
m Text replacement - "{\| " to "{| class="wikitable" " |
||
| Line 43: | Line 43: | ||
Common compression algorithms used in conjunction with tar are: | Common compression algorithms used in conjunction with tar are: | ||
{| | {| class="wikitable" | ||
! Algorithm | ! Algorithm | ||
! Flag | ! Flag | ||
Revision as of 01:37, 1 September 2019
This is about the unix tar command.
Basic Usage
Create Archive
Use the -c option to create.
$ tar -cf archive.tar file1 file2 ...
List Archive Contents
Use the -t option to list contents.
$ tar -tf archive.tar
file1
file2
Extracting Files
To extract everything, use the -x.
$ tar -xf archive.tar
$ ls
file1
file2
To extract only a specific file or folder, pass the filename or path name after the archive.
$ tar -xf archive.tar file1
$ ls
file1
To extract based on a pattern:
$ tar -xf archive.tar --wildcards --no-anchored '*le1'
$ ls
file1
Compression
Common compression algorithms used in conjunction with tar are:
| Algorithm | Flag | Extension |
|---|---|---|
| gzip | -z
|
.tar.gz, .tgz |
| bzip2 | -j
|
.tar.bz2, .tbz2 |
| xz | -J
|
.tar.xz |
Add the flag when creating or extracting using tar.