Last active
July 21, 2019 05:58
-
-
Save estysdesu/9e0ca3c5af909d2a5290e23403fa0435 to your computer and use it in GitHub Desktop.
[Shell: file compression and archiving] #tar #gzip #sh #bzip #xz #zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### tar (ARCHIVING) ##### | |
# -z: gzip | |
# -j: bzip2 | |
# -J: xz | |
# if compression method is missing, tar tries to guess compression method (from extension) | |
# -c: create | |
# -x: extract | |
# -v: verbose (list each file) | |
# -f: archive file name | |
# -r: append to unzipped archive | |
# -t: list archive contents | |
# -C: change the directory before adding the following files or before extracting the archive | |
tar -zcvf <file.tar.gz> <file-1> <file-2> <dir-3> | |
tar -jcvf <file.tar.gz> <file-1> <file-2> <dir-3> | |
tar -zxvf <file.tar.gz> # extract to current directory | |
tar -zxvf <file.tar.gz> -C <dir> # extract to dir | |
tar -jxvf <file.tar.bz2> <file-1> <dir-2> # extract just file-1 and dir-2 from bzip2 archive | |
##### bzip2/bunzip2 (COMPRESSION) ##### | |
# -d: decompress | |
# -k: keep uncompressed input files also | |
# -v: verbose (show stats for each compressed file) | |
# -#: compression level (1-9) | |
bzip <file-1> <dir-2> # compress each file individually | |
##### gzip/gunzip (COMPRESSION) ##### | |
# -k: keep uncompressed input files also | |
# -d: decompress | |
# -l: compression stats | |
# -r: recursive | |
# -v: verbose (show stats for each compressed file) | |
# -#: compression level (1-9) | |
gzip -r <dir-1> <file-2> # compresses each file individually | |
##### zip/unzip (ARCHIVING & COMPRESSION) ##### | |
# -r: recursive | |
# -g: grow/append to an already zipped file | |
# -d: delete file from archive | |
# -l: list archive files | |
zip <zip-file> <file-1> <file-2> <dir-3> | |
zip -r <zip-file> <file-1> <dir-2> | |
unzip <zip-file> <file-1> <dir-2> # extract just file-1 and dir-2 from zip archive | |
##### xz/unxz (COMPRESSION) ##### | |
# -k: keep uncompressed input files also | |
# -d: decompress | |
xz -d <xz-file> | |
#### MANUAL PIPING ##### | |
tar -cvf - <file-1> <file-2> <dir-3> | gzip > archive.tar.gz # manual |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment