mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
2.7 KiB
2.7 KiB
Tar
TL;DR
# Create archives.
tar czvf 'directory.tar.gz' 'source-directory'
tar -capvf 'archive.tar.bz2' 'directory1' 'directory2' 'file1' 'fileN'
# List the content of archives.
tar tf 'archive.tar'
tar -tf 'archive.tar' 'file-in-archive'
# Test archives by reading their contents or extracting them to stdout.
tar tf 'archive.tar' > '/dev/null'
tar tOf 'archive.tar' > '/dev/null'
# Extract archives.
tar xpf 'archive.tar'
tar xapf 'archive.tar.gz'
tar -xjpOf 'archive.tar.bz2' 'file-in-archive'
Options of interest
| Short | Long | Description |
|---|---|---|
-a |
--auto-compress |
use archive suffix to determine the compression program |
-c |
--create |
create a new archive; directories are archived recursively, unless the --no-recursion option is given |
-C |
--directory DIR |
change to DIR before performing any operations; this option affects all options that follow |
-f |
--file FILE |
use archive file or device FILE; if not given, tar will first examine the environment variable TAPE and default to the compiled-in default |
-r |
--append |
append files to the end of an archive |
-t |
--list |
list the contents of an archive; arguments are optional, but when given they specify the names of the members to list |