From 68758d5b264b95b58306ca8d2725a8ed026a2e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Doubinine?= Date: Thu, 11 Aug 2022 23:40:12 +0200 Subject: [PATCH] Add tar cheatsheet (#1870) Co-authored-by: Zed --- tar.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tar.md diff --git a/tar.md b/tar.md new file mode 100644 index 000000000..2c1d27a82 --- /dev/null +++ b/tar.md @@ -0,0 +1,46 @@ +--- +title: tar +category: CLI +layout: 2017/sheet +updated: 2022-08-11 +intro: Concatenate, Deflate, Inflate files +--- +## Reference +{:.-two-column} + +### Deflate / Inflate / Concatenate +```shell +# Deflate / Compress +tar -czf archive.tar.gz /path/files +``` + +```shell +# Inflate / Uncompress +tar -xzf archive.tar.gz +``` + +```shell +# Concatenate files into a single tar +tar -cf archive.tar /path/files +``` + +```shell +# Extract file to a defined directory +tar -xzf archive.tar.gz -C /target/directory +``` + +```shell +# Append a file to an existing archive +tar -zu archive.tar.gz -C /target/file +``` + +### Common options + +| Option | Description | +|--------|--------------------------------------------------------------------------| +| `z` | compress with gzip | +| `c` | create an archive | +| `u` | append files which are newer than the corresponding copy ibn the archive | +| `f` | filename of the archive | +| `v` | verbose, display what is inflated or deflated | +| `a` | unlike of `z`, determine compression based on file extension |