slothsoffun
3/21/2018 - 10:59 AM

Compression

# TAR (archives without compression)

## Modes
-c  create an archive (files to archive, archive from files)
-x  extract an archive (archive to files, files from archive)

## Options
-f FILE  name of archive - must specify unless using tape drive for archive *must be last*
-v       be verbose, list all files being archived/extracted
-z       create/extract archive with gzip/gunzip
-j       create/extract archive with bzip2/bunzip2
-J       create/extract archive with XZ

tar -cf archive.tar foo bar  # Create archive w/ foo and bar
tar -tvf archive.tar          # List files of archive verbosly
tar -xf archive.tar         # Extract archive
tar -xvzf archive.tar

# ZIP
unzip archive.zip -d /opt
zip -r archive.zip *.jpg

# GZIP (single files only)
gzip $file # creates $file.gz
gunzip $gz_file
## Options
-c  Write compressed file to stdout. Do not delete original file.
-d  Act like gunzip.
-1  Performance: Use fast compression (somewhat bigger result)
-9  Performance: Use best compression (somewhat slower)