当前位置:首页 > 编程笔记 > 正文
已解决

Linux常用指令(四)——压缩/解压缩工具

来自网友在路上 179879提问 提问时间:2023-11-05 20:00:55阅读次数: 79

最佳答案 问答题库798位专家为你答疑解惑

Linux压缩/解压缩工具

      • 4.1 zip压缩文件
      • 4.2 unzip解压缩文件
      • 4.3 tar压缩
      • 4.4 tar解压

更加完整的Linux常用指令
压缩包文件格式

Windows: *.zip*.7z

Linux: *.zip*.7z**.rar*.gz*.xz*.bz2*.tar等等

4.1 zip压缩文件

# 使用zip打包文件夹test
# -r为递归打包包含子目录的全部内容,-q为安静模式,-o表示输出文件
cd /home/test
zip -r -q -o test.zip /home/mydir# -e参数加密压缩
zip -r -e -o test.zip /home/mydir

4.2 unzip解压缩文件

# 解压到当前目录
unzip test.zip# -q安静模式,解压到指定目录
unzip -q test.zip -d mydir# 不解压只查看压缩包的内容
unzip -l test.zip# 解压中文压缩包
unzip -O GBK 中文压缩文件.zip

4.3 tar压缩

# 打包test文件
# -P:保留绝对路径
# -c:创建一个tar包
# -f:指定创建文件名
cd /home/test
tar -P -cf test.tar /home/mydir

4.4 tar解压

# 解包一个文件(-x参数)到指定路径的已存在目录(-C参数)
mkdir mydir
tar -xf test.tar -C mydir# -t参数,只查看不解包
tar -tf test.tar# 解压*.tar.gz文件,-z参数
tar -xzf test.tar.gz
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"Linux常用指令(四)——压缩/解压缩工具":http://eshow365.cn/6-32967-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!