• 【Linux】.gz文件 压缩与解压缩命令


    一、.gz文件压缩与解压缩命令:

    1.压缩文件
    gzip 源文件
    如压缩 b.txt 使用命令 gzip b.txt 注意 压缩为 .gz 文件 源文件会消失
    如果想保留源文件 使用命令 gzip -c 源文件 > 压缩文件

    [root@localhost ~]# gzip -c b.txt > b.txt.gz
    [root@localhost ~]# ll
    total 8
    -rw-------. 1 root root 951 Apr 24  2017 anaconda-ks.cfg
    -rw-r--r--. 1 root root   0 May 19 11:37 b.txt
    -rw-r--r--. 1 root root  26 May 19 11:38 b.txt.gz
    

    2.压缩目录
    gzip -r 目录
    注意 gzip 压缩目录 只会递归地压缩目录下的所有文件 不会压缩目录

    [root@localhost ~]# tree -L 3 annie/
    annie/
    ├── 7.txt
    └── sm8250
        ├── b.txt
        └── test
            └── 1.txt
    
    2 directories, 3 files
    [root@localhost ~]# gzip -r annie
    [root@localhost ~]# tree -L 3 annie/
    annie/
    ├── 7.txt.gz
    └── sm8250
        ├── b.txt.gz
        └── test
            └── 1.txt.gz
    
    2 directories, 3 files
    

    3.解压

    [root@localhost annie]# ll
    total 4
    -rw-r--r--. 1 root root 26 May 19 11:40 7.txt.gz
    drwxr-xr-x. 3 root root 32 May 19 11:41 sm8250
    [root@localhost annie]# gzip -d 7.txt.gz 
    [root@localhost annie]# ll
    total 0
    -rw-r--r--. 1 root root  0 May 19 11:40 7.txt
    drwxr-xr-x. 3 root root 32 May 19 11:41 sm8250
    
  • 相关阅读:
    C语言-第0次作业
    ubuntu 安装maven
    微服务运行在 Docker 之上
    docker入门
    springcloud-Sleuth 与 Zipkin 结合图形化展示
    Spring Cloud Config 配置管理
    springcloud-Zuul 网关
    springcloud-Hystrix 容错处理
    springcloud-Feign 声明式 REST 调用
    springcloud-Ribbon 客户端负载均衡
  • 原文地址:https://www.cnblogs.com/wucaiyun1/p/12917316.html
Copyright © 2020-2023  润新知