OSDN Git Service

Regular updates
[twpd/master.git] / tar.md
1 ---
2 title: tar
3 category: CLI
4 layout: 2017/sheet
5 updated: 2022-08-11
6 intro: Concatenate, Deflate, Inflate files
7 ---
8 ## Reference
9 {:.-two-column}
10
11 ### Deflate / Inflate / Concatenate
12 ```shell
13 # Deflate / Compress
14 tar -czf archive.tar.gz /path/files
15 ```
16
17 ```shell
18 # Inflate / Uncompress
19 tar -xzf archive.tar.gz
20 ```
21
22 ```shell
23 # Concatenate files into a single tar
24 tar -cf archive.tar /path/files
25 ```
26
27 ```shell
28 # Extract file to a defined directory
29 tar -xzf archive.tar.gz -C /target/directory
30 ```
31
32 ```shell
33 # Append a file to an existing archive
34 tar -zu archive.tar.gz -C /target/file
35 ```
36
37 ### Common options
38
39 | Option | Description                                                              |
40 |--------|--------------------------------------------------------------------------|
41 | `z`    | compress with gzip                                                       |
42 | `c`    | create an archive                                                        |
43 | `u`    | append files which are newer than the corresponding copy ibn the archive |
44 | `f`    | filename of the archive                                                  |
45 | `v`    | verbose, display what is inflated or deflated                            |
46 | `a`    | unlike of `z`, determine compression based on file extension             |