压缩格式主要有.zip .gz .bz2等多种
分别是zip gzip bzip2等工具的输出格式
1. zip
常用命令: zip unzip zipinfo
压缩
  [01:35:28] ~/bash $ zip a.zip ziptest/*
  adding: ziptest/a.c (stored 0%)
  adding: ziptest/b.c (stored 0%)
  [01:35:46] ~/bash $ ll
total 16
drwxrwxr-x  3 develon develon 4096 Jan 19 01:35 ./
drwxr-xr-x 16 develon develon 4096 Jan 19 00:25 ../
-rw-rw-r--  1 develon develon  480 Jan 19 01:35 a.zip
drwxrwxr-x  2 develon develon 4096 Jan 19 01:31 ziptest/
-r选项很有用
  [01:38:00] ~/bash $ zip -r b.zip ./ziptest
  adding: ziptest/ (stored 0%)
  adding: ziptest/b.c (stored 0%)
  adding: ziptest/a.c (stored 0%)
zipinfo查看zip信息
  [01:35:49] ~/bash $ zipinfo a.zip
Archive:  a.zip
Zip file size: 480 bytes, number of entries: 3
drwxrwxr-x  3.0 unx        0 bx stor 19-Jan-19 01:31 ziptest/
-rw-rw-r--  3.0 unx        7 tx stor 19-Jan-19 01:31 ziptest/a.c
-rw-rw-r--  3.0 unx        7 tx stor 19-Jan-19 01:31 ziptest/b.c
3 files, 14 bytes uncompressed, 14 bytes compressed:  0.0%
unzip也可以查看文件列表
  [01:42:56] ~/bash $ unzip -l a.zip
Archive:  a.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2019-01-19 01:31   ziptest/
        7  2019-01-19 01:31   ziptest/a.c
        7  2019-01-19 01:31   ziptest/b.c
---------                     -------
       14                     3 files
zipgrep可以直接查找文本
  [01:35:55] ~/bash $ zipgrep c a.zip
ziptest/a.c:// a.c
ziptest/b.c:// b.c
解压
  [01:47:02] ~/bash $ unzip a.zip ziptest/a.c -d a
Archive:  a.zip
 extracting: a/ziptest/a.c
  [01:47:22] ~/bash $ tree
.
├── a
│   └── ziptest
│       └── a.c
└── a.zip
2 directories, 2 files
归档文件, 文件(夹)的集合, Linux下的归档文件格式为.tar, .tar常用来归档.gz文件, 即.gz.tar文件
Usage: tar [OPTION...] [FILE]...
GNU ‘tar‘ saves many files together into a single tape or disk archive, and can
restore individual files from the archive.
GNU‘tar‘将许多文件一起保存到单个磁带或磁盘存档中,并且可以
从归档中恢复单个文件。
Examples:
  tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
  tar -tvf archive.tar         # List all files in archive.tar verbosely.
  tar -xf archive.tar          # Extract all files from archive.tar.
Main operation mode:
  -A, --catenate, --concatenate   append tar files to an archive
  -c, --create               create a new archive
  -d, --diff, --compare      find differences between archive and file system
      --delete               delete from the archive (not on mag tapes!)
  -r, --append               append files to the end of an archive
  -t, --list                 list the contents of an archive
      --test-label           test the archive volume label and exit
  -u, --update               only append files newer than copy in archive
  -x, --extract, --get       extract files from an archive
  -f, --file=ARCHIVE         use archive file or device ARCHIVE
  -z, --gzip, --gunzip, --ungzip   filter the archive through gzip
  -H, --format=FORMAT        create archive of the given format
 FORMAT is one of the following:
    gnu                      GNU tar 1.13.x format
    oldgnu                   GNU format as per tar <= 1.12
    pax                      POSIX 1003.1-2001 (pax) format
    posix                    same as pax
    ustar                    POSIX 1003.1-1988 (ustar) format
    v7                       old V7 tar format
  -C, --directory=DIR        change to directory DIR
  -v, --verbose              verbosely list files processed
  -o                         when creating, same as --old-archive; when
                             extracting, same as --no-same-owner
例子:
  tar -cf archive.tar foo bar#从文件foo和bar创建archive.tar。
  tar -tvf archive.tar#详细列出archive.tar中的所有文件。
  tar -xf archive.tar#从archive.tar中提取所有文件。
主要操作方式:
  -A,		将tar文件附加到存档
  -c, 	创建一个新的存档
  -d,	--diff	比较存档和文件系统之间的差异
    --delete  	删除存档中的删除(不在磁带上!)
  -r, --append	将文件追加到存档的末尾
  -t, --list	列出存档的内容
      --test-label	测试存档卷标并退出
  -u, --update	仅附加比归档中的副本更新的文件
  -x, --extract, --get	从存档中提取文件
  -f, --file=ARCHIVE	使用存档文件或设备存档
  -z, --gzip, --gunzip, --ungzip	通过gzip过滤存档
  -H, --format = FORMAT	创建给定格式的存档
 FORMAT是以下之一:
    gnu GNU tar 1.13.x格式
    oldgnu GNU格式,根据tar <= 1.12
    pax POSIX 1003.1-2001(pax)格式
    posix与pax相同
    ustar POSIX 1003.1-1988(ustar)格式
    v7旧的V7 tar格式
  -C, --directory=DIR		DIR更改到目录DIR
  -v, --verbose	详细列出已处理的文件
  -o 	创建时,与--old-archive相同;提取时,与--no-same-owner相同
原文:https://www.cnblogs.com/develon/p/10293308.html