zoukankan      html  css  js  c++  java
  • linux 打包压缩工具

    以.gz结尾 gzip 压缩工具压缩的文件
    gzip+文件名
    [root@test ~]# gzip 2.txt
    [root@test ~]# ls
    2.txt.gz test
    gzip -d +压缩包
    [root@test ~]# gzip -d 2.txt.gz
    [root@test ~]# ls
    2.txt test
    不支持压缩目录
    [root@test ~]# gzip test
    gzip: test is a directory — ignored
    支持一起压缩多个文件
    [root@test ~]# gzip 1.txt 2.txt
    [root@test ~]# ls
    1.txt.gz 2.txt.gz test
    以.bz2结尾 bzip2 压缩工具压缩的文件
    和gzip压缩方式同理
    .tar需要命名 tar打包程序打包的文件(tar并没有压缩功能,只是把一个目录合并成一个文件)
    需要在-f 后面加打包名 -f要放在组合键的最后
    [root@test ~]# tar -cvf all.tar 1.txt 2.txt test
    1.txt
    2.txt
    test/
    test/1.txt
    [root@test ~]# ls
    1.txt 2.txt all.tar test
    查看打包包含哪些文件
    [root@test ~]# tar -tf all.tar
    1.txt
    2.txt
    test/
    test/1.txt
    解压打包
    [root@test ~]# tar -xvf all.tar 1.txt 2.txt test
    1.txt
    2.txt
    test/
    test/1.txt
    [root@test ~]# ls
    1.txt 2.txt all.tar test
    可以看出打包并没有消失,而gzip和bzip2在解压后压缩包消失了 c 是创建一个包的意思 x是解开一个包的意思 v是可视化的意思,可以省略。
    .tar.gz需要命名 可以理解为先用tar打包,然后再gzip压缩
    先打包再以gzip的形式压缩
    [root@test ~]# tar -zcvf all.tar.gz 1.txt 2.txt test
    1.txt
    2.txt
    test/
    test/1.txt
    [root@test ~]# ls
    1.txt 2.txt all.tar all.tar.gz test
    all.tar 和 all.tar.gz的区别就是后者是压缩文件 前者只是打包
    解包并解压缩
    [root@test ~]# rm -rf 1.txt 2.txt test/
    [root@test ~]# ls
    all.tar all.tar.gz
    [root@test ~]# tar -zxvf all.tar.gz
    1.txt
    2.txt
    test/
    test/1.txt
    [root@test ~]# ls
    1.txt 2.txt all.tar all.tar.gz test
    .tar.bz2需要命名 同上,先用tar打包,然后再bzip2压缩
    原理同上 打包压缩
    [root@test ~]# tar -jcvf all.tar.bz2 1.txt 2.txt test
    1.txt
    2.txt
    test/
    test/1.txt
    解包解压缩
    [root@test ~]# tar -jxvf all.tar.bz2 1.txt 2.txt test
    1.txt
    2.txt
    test/
    test/1.txt
    不同的是 gzip是以z来表示压缩解压缩 bzip2 是以j表示来压缩解压缩
    ————————————————————-
    打包 和 打包压缩 -f 后面紧跟的文件需要自己命名,为了能够辨识以哪些是打包文件,用的哪种方式压缩 默认后缀就按各自的方式命名即可,以免日后忘记当时的打包文件和压缩方式。

  • 相关阅读:
    Erlang学习笔记2
    erlang的Socket参数含义
    Erlang 日期和时间处理、时间戳转换
    图(有向)-拓扑排序
    图(无向连通无权图)-广度优先搜索
    图(无向连通无权图)-深度优先搜索
    图(无向连通无权值图)深度优先生成最小生成树
    客户关系管理系统
    字符串类
    I/O流
  • 原文地址:https://www.cnblogs.com/dantes91/p/4671107.html
Copyright © 2011-2022 走看看