linux解压缩

2019-11-24  本文已影响0人  夜空痕

解压缩
工作中,有两种常用的解压缩zip和unzip和tar格式的;
首先在这里介绍下tar格式
tar解压缩命令,tar解压缩命令可以处理tar,tar.gz,tgz,tar.bz2后缀的文件
涉及的参数:

常用的组合命令:
tar -zcvf xxx.tar.gz file1 file2 # 将文件压缩为.tar.gz
tar -xvf xxx.tar.gz #解压文件到当前文件夹
tar -xvf xxx.tar.gz -C dir # 将文件解压到指定文件夹,在实际中通常使用的是这种
例如:

root@JD:/home/yj/test# tar -zcvf  logs.tar.gz test1.log  test2.log  test.log
test1.log
test2.log
test.log
root@JD:/home/yj/test# ls
logs.tar.gz  test1.log  test2.log  test.log  z
root@JD:/home/yj/test# ls
logs.tar.gz  test1.log  test2.log  test.log  z
root@JD:/home/yj/test# rm -rf test1.log  test.log  test2.log z
root@JD:/home/yj/test# ls
logs.tar.gz
root@JD:/home/yj/test# tar -xvf logs.tar.gz
test1.log
test2.log
test.log
root@JD:/home/yj/test# ls
logs.tar.gz  test1.log  test2.log  test.log

uzip和zip主要用于处理zip包

zip -r test.zip test/   #将test目录下的文件压缩到test.zip文件夹
zip -rj test.zip test/ #打包test目录下文件,且压缩包不带test目录
unzip -o test.zip -d dir #讲test.zip解压到dir目录
上一篇 下一篇

猜你喜欢

热点阅读