zip files

view zip files contents
unzip -l [file]
less [file]
view [file]


zip all files in a directory
zip *
zip directory recursive
zip -r [directory]
exclude files
zip * -x 'ignore1.txt' -x 'ignore2.txt'
zip -r [file] . -x '.git/**'


efficiently merge multiple zip files into a single zip file
zipmerge [destination] [source]...


create an encrypted zip wit password protection
7za a -tzip -p[password] -mem=AES256 [directory]


unzip complete zip file
unzip files matching a pattern
unzip -j jenkins.war 'WEB-INF/lib/cli-*.jar'
dump specific zipped file to console
unzip -c '[file_in_zip]'
unzip complete zip to a directory
unzip -d destination_folder
skip existing files without prompt
unzip -n
overwrite existing files without prompt
unzip -o
unzip multiple zip files (use quotes)
unzip '*.zip'

.gz files

zip and delete single file
gzip [file]
zip and keep single file
gzip -k [file]
unzip single .gz file
gunzip [file]

tar files

v: verbose => list all files
x: extract files (as opposed to collecting)
z: decompress using gzip (required for .gz files)
f: file => this must be the last flag of the command, and the tar file must be immediately after.

-C [dir]       => specify unpack directory
--remove-files => remove files from disk after adding them to the archive
Extracting a tar archive
tar -xf [name].tar
extract in specified directory
tar -xf [name].tar -C [dir]
create tar file
tar -cvf output.tar [file]...

tar.gz files

list all files
tar -tzf [name].tar.gz
list all files verbose (access, size, timestamp)
tar -vtzf [name].tar.gz
Extracting a tar.gz archive
tar -zxf [name].tar.gz
-v for verbose => prints all files while extracting
tar -vzxf [name].tar.gz
strip container folder (don't create unnecessary directory, extract to root)
tar -zxf [name].tar.gz --strip 1
extract to specified directory
tar -zxf [name].tar.gz -C [directory]
create tar.gz file
tar -czvf output.tar.gz [file]...