linux tar.gz zip 解压缩 压缩命令

-------------------- tar --------------------

打包命令tar
tar -cvf 打包文件名 源文件
option:
    -c: 打包
    -v: 显示过程
    -f: 指定打包后的文件名
    -z: 压缩为.tar.gz格式
example:
    tar -cvf xxxx.tar xxxx
    tar -zxvf 压缩包名.tar.gz 源文件
压缩文件列表和目录到ddd.tar
tar -cvf public/ddd.tar .env vendor composer.lock 
压缩文件列表(包含软链的实际文件)和目录到ddd.tar
tar -hcvf public/ddd.tar .env vendor composer.lock 


解压example:
    tar -zxvf file.tar.gz
    tar -jxvf file.tar.bz2
    tar -jxvf file.tar.bz2 -C /tmp/ # 指定解压缩位置
    tar -zcvf xx1.tar.gz xx1 xx2 xx3 # 压缩多个文件
    tar -ztvf xxx.tar.gz # 只是查看压缩文件, 不解压

标签: none

添加新评论