Index

Table of contents

zip files

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

zip

view files contained in zip archive
less [zip-file]
zip all files in a directory
zip file.zip *
zip directory recursive
zip -r file.zip [directory]
exclude files
zip * -x 'ignore1.txt' -x 'ignore2.txt'
zip -r [file] . -x '.git/**'
no compression (just store)
zip -0 [archive] [file]+
split into 1GB chunks
zip -s 1g [archive] [file]+

zipmerge

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

7za

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

unzip

unzip complete zip file
unzip file.zip
unzip files matching a pattern
unzip -j jenkins.war 'WEB-INF/lib/cli-*.jar'
dump specific zipped file to console
unzip -c file.zip '[file_in_zip]'
unzip complete zip to a directory
unzip file.zip -d destination_folder
skip existing files without prompt
unzip -n file.zip
overwrite existing files without prompt
unzip -o file.zip
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

flags
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
--list         => file listing
--remove-files => remove files from disk after adding them to the archive
listing files in a tar archive
tar --list < [tar-file]
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]...

rar files

list file contents
rar l [archive]
create archive / add to archive
rar a [archive] [file]...
extract archive in current directory
rar x [archive]
unrar x [archive]
extract archive in new directory (prepend directory name)
rar x -ad foo.rar
unrar x -ad foo.rar

7zip files

list archive contents
7z l [archive]
create archive
7z a [archive] [file]...
unpack & delete archive
p7zip -d [archive]
unpack archive (do not delete original file)
p7zip -k -d [archive]
7z x [archive]
extract to a specific directory
7z x [archive] -o[directory]