7z

7z命令行工具使用总结

关于7z命令行工具,不论是Mac中的7z,还是CentOS中的7za,其用法都是一样的

压缩

压缩=创建7z文件

7z a compressed_filename.7z folder_to_compress/
7za a compressed_filename.7z file_to_compress

参数解释:

  • a: Add files to archive

举例:

  • 压缩目录
      7z a gitbook_src_root.7z gitbook_src_root/
    
  • 压缩文件

      7z a gitbook_src_root.7z gitbook_src_root/
      7za a crifan_wp_db.7z crifan_wp_db.sql
    
    • 完整log

      # 7za a crifan_wp_db.7z crifan_wp_db.sql 
      
      7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
      p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Virtual CPU 82d9ed4018dd (50654),ASM,AES-NI)
      
      Scanning the drive:
      1 file, 335432935 bytes (320 MiB)
      
      Creating archive: crifan_wp_db.7z
      
      Items to compress: 1
      
      Files read from disk: 1
      Archive size: 31722755 bytes (31 MiB)
      Everything is Ok
      

更复杂点的用法

7za a -t7z -r -bt output_filename.7z folder_to_compress/*
7za a -t7z -r -bt output_filename.7z file_to_compress

参数解释:

  • -t{Type}: Set type of archive
  • -r[-|0]: Recurse subdirectories
  • -bt: show execution time statistics

举例:

7za a -t7z -r -bt www.crifan.com_allFiles_20180320.7z /home/wwwroot/www.crifan.com/*

解压缩

解压缩=解压缩7z文件

7z e to_uncompress_file.7z
7z x to_uncompress_file.7z

参数解释:

  • e: Extract files from archive (without using directory names)
    • 解压缩 不保留原先目录结构
  • x: eXtract files with full paths
    • 解压缩 保留原先目录结构

举例:

7z e www.crifan.com_allFiles_20190509.7z
7z x www.crifan.com_allFiles_20190509.7z

results matching ""

    No results matching ""