rar
rar a xxx.rar files...
rar e xxx.rar ./
rar a -p123456 xxx.rar files...
rar e -p123456 xxx.rar ./
rar a -v20m xxx.rar files...
tar
常用的参数说明(grep "^ \-[a-zA-Z0-9]" <(tar --help) | sort
):
vf
分别表示输出详细信息、指定压缩包名称x
解压c
压缩t
列出压缩包里面的文件列表- 压缩文件类型(Linux 下最常用的两种):
z
:gzj
:bz2
# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/
# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
# To create a .gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
# To list the content of an .gz archive:
tar -ztvf /path/to/foo.tgz
# To extract a .bz2 archive:
tar -xjvf /path/to/foo.tgz
# To create a .bz2 archive:
tar -cjvf /path/to/foo.tgz /path/to/foo/
# To list the content of an .bz2 archive:
tar -jtvf /path/to/foo.tgz
# To create a .gz archive and exclude all jpg,gif,... from the tgz
tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/
# To use parallel (multi-threaded) implementation of compression algorithms:
tar -z ... -> tar -Ipigz ...
tar -j ... -> tar -Ipbzip2 ...
tar -J ... -> tar -Ipixz ...
zip
# Create zip file
zip archive.zip file1 directory/
# To list, test and extract zip archives, see unzip
cheat unzip
# Extract archive
unzip archive.zip
# Windows 下创建的压缩包放到 Ubuntu 下解压可能会有编码问题
unzip archive.zip -O gbk
# Test integrity of archive
unzip -tq archive.zip
# List files and directories in a file
unzip -l archive.zip
7z
sudo apt install p7zip-full
dpkg -L p7zip-full p7zip | grep bin/
# /usr/bin/7z
# /usr/bin/7za
# /usr/bin/7zr
# /usr/bin/p7zip
文档中说是支持 7z,xz,tar,gz,zip,bz2,iso,rpm,deb 等等等等格式,不过没用过。
# 压缩
7z a xxxx.7z files...
# 解压
7z e xxxx.7z
# 查看文件列表
7z l xxxx.7z
参考
man
--help
cheat
/tldr