Create a high-compression-level solid-compression archive in 7z format
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on dir`date +%Y%m%d%H%M%S`.7z dir
Remarks:
-si
gets the input from stdin-m0=lzma2
use the LZMA2 compression method (See this superuser.com thread for information about LZMA2 method). Use only when GBs of memory is available.-mx=9
highest compression level-ms=on
creates a solid compression, (tar-based formats that are solid compressions includetar.bz2
,tar.gz
) TODO
Optionally create a tarball first
$ tar cfv - dir/ | 7z a -si -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on dir`date +%Y%m%d%H%M%S`.tar.7z
Remarks:
-
creates the default tarball filename
Create a multi-volume ZIP archive
$ 7z a -tzip -v14m archive.zip largedir/
Create a password protected archive and extract it
$ 7z a -t7z -p myarchive.7z file1.txt file2.png *.cpp
Extract it:
$ 7z x myarchive.7z
Create compressed multi-volume archive of a directory of multiple files and subdirectories
$ 7z a -t7z -mx=5 -v100m largedir ~/Desktop/Downloading/largedir/
7-Zip 9.04 beta Copyright (c) 1999-2009 Igor Pavlov 2009-05-30
p7zip Version 9.04 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Scanning
Creating archive largedir.7z
Compressing largedir/largefile1.avi
Compressing largedir/largefile2.avi
Compressing largedir/largefile3.avi
Compressing largedir/largefile4.avi
Everything is Ok
Extract
$ 7z e largedir.7z.001
7-Zip 9.04 beta Copyright (c) 1999-2009 Igor Pavlov 2009-05-30
p7zip Version 9.04 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Processing archive: largedir.7z.001
Extracting largedir/largefile1.avi
Extracting largedir/largefile2.avi
Extracting largedir/largefile3.avi
Extracting largedir/largefile4.avi
Extracting largedir/largefile5.avi
Extracting largedir
Everything is Ok
Folders: 1
Files: 5
Size: 463073364
Compressed: 104857600
$
Remarks:
-t7z
specifies type as7z
-v100m
specifies volume size to be at most 100MB-mx=5
specifies level of compression in range 0 - 9 with 9 being the most compressedlargedir
is the name of the resultant archive, and if multiple volumes are created, the names arelargedir.001
,largedir.002
, etc.