美文网首页
【Linux】Linux上如何在不解压的情况下查看压缩包中文件列

【Linux】Linux上如何在不解压的情况下查看压缩包中文件列

作者: Bogon | 来源:发表于2023-10-22 17:14 被阅读0次
# tar  --help   | grep   list

  -t, --list                 list the contents of an archive

# tar -cf  CentOS.tar  CentOS/

# tar  -tvf CentOS.tar
drwxr-xr-x root/root         0 2023-07-04 14:38 CentOS/
-rw-r--r-- root/root       703 2022-08-05 01:56 CentOS/sha256sum.txt
-rw-r--r-- root/root      1563 2022-08-05 01:58 CentOS/sha256sum.txt.asc

命令 tar -tvf CentOS.tar 的详细解读如下:

  • tar: 用于创建、查看和提取归档文件的命令。
  • -t: 选项表示查看压缩包中的文件列表而不进行提取或解压缩操作。
  • -v: 选项表示以详细模式运行tar命令,输出操作的详细信息。
  • -f CentOS.tar: 指定要处理的归档文件为CentOS.tar

因此,该命令的作用是以详细模式查看.tar文件CentOS.tar中的文件列表。
命令的输出会显示压缩包中的每个文件的相关信息,包括文件名、权限、所有者、大小和修改日期等。
请注意,由于没有使用压缩选项(如-z),所以这里假设CentOS.tar是一个未压缩的.tar文件。

# tar -zvtf   yum.tar.gz

drwxr-xr-x root/root         0 2023-10-18 21:28 yum/
-rw-r--r-- root/root     16416 2023-10-18 21:27 yum/crontabs-1.11-21.ky10.noarch.rpm
-rw-r--r-- root/root     21432 2023-10-18 21:27 yum/ima-evm-utils-libs-1.3.1-6.ky10.x86_64.rpm
-rw-r--r-- root/root     82044 2023-10-18 21:27 yum/crypto-policies-20200619-1.git781bbd4.ky10.noarch.rpm
-rw-r--r-- root/root     88584 2023-10-18 21:27 yum/zlib-1.2.11-22.ky10.x86_64.rpm
-rw-r--r-- root/root    339964 2023-10-18 21:27 yum/p11-kit-0.23.20-4.ky10.x86_64.rpm
-rw-r--r-- root/root    124756 2023-10-18 21:27 yum/p11-kit-trust-0.23.20-4.ky10.x86_64.rpm
-rw-r--r-- root/root   1555964 2023-10-18 21:27 yum/mpfr-4.1.0-1.ky10.x86_64.rpm
-rw-r--r-- root/root     84820 2023-10-18 21:27 yum/libtirpc-1.2.6-2.p02.ky10.x86_64.rpm
-rw-r--r-- root/root    398192 2023-10-18 21:27 yum/findutils-4.7.0-5.p01.ky10.x86_64.rpm
drwxr-xr-x root/root         0 2023-10-18 21:28 yum/repodata/
-rw-r--r-- root/root     99296 2023-10-18 21:28 yum/repodata/5e50c9e274bff71e2b0e4bc2c59628eb7c839c4701805b02a30e718965dd0d7c-primary.xml.gz
-rw-r--r-- root/root    159419 2023-10-18 21:28 yum/repodata/eb3bfe4dd5dd7e0849414d40bb5059019336e5b70e066f88621061499064b7bf-filelists.xml.gz
-rw-r--r-- root/root     48082 2023-10-18 21:28 yum/repodata/9695d2937d874d88e59d0058aaa34cc94a2e501b12433602e5aec412500c2bed-other.xml.gz
-rw-r--r-- root/root    194958 2023-10-18 21:28 yum/repodata/6e860921c225c3a8e2814a50c1877c394239a51329d47581d179963fcf5efccf-primary.sqlite.bz2
-rw-r--r-- root/root    170745 2023-10-18 21:28 yum/repodata/e51e63f48b6bfff282e8e425d117acc46ef71acd478c77040f3ed6e8d9ba4726-filelists.sqlite.bz2
-rw-r--r-- root/root     58517 2023-10-18 21:28 yum/repodata/adcfa00ec426b384c5fe92e99b33db13a92da8ca3f605c2e31d90bdba1b5e0c2-other.sqlite.bz2
-rw-r--r-- root/root      3094 2023-10-18 21:28 yum/repodata/repomd.xml

命令 tar -zvtf yum.tar.gz 的详细解读如下:

  • tar: 用于创建、查看和提取归档文件的命令。
  • -z: 选项表示使用gzip来压缩或解压缩文件。在这里,它告诉tar命令使用gzip来解压缩.tar.gz文件。
  • -v: 选项表示以详细模式运行tar命令,输出操作的详细信息。
  • -t: 选项表示查看压缩包中的文件列表而不进行提取或解压缩操作。
  • -f yum.tar.gz: 指定要处理的归档文件为yum.tar.gz

因此,该命令的作用是以详细模式查看.tar.gz文件yum.tar.gz中的文件列表。
命令的输出会显示压缩包中的每个文件的相关信息,包括文件名、权限、所有者、大小和修改日期等。

# zip  --help

Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -e   encrypt                      -n   don't compress these suffixes
  -h2  show more help

# zip   -r   openssh-7.4p1.zip  openssh-7.4p1

  adding: openssh-7.4p1/ (stored 0%)
  adding: openssh-7.4p1/openssh-7.4p1-23.el7_9.x86_64.rpm (deflated 10%)
  adding: openssh-7.4p1/openssh-clients-7.4p1-23.el7_9.x86_64.rpm (deflated 8%)
  adding: openssh-7.4p1/openssh-server-7.4p1-23.el7_9.x86_64.rpm (deflated 11%)

命令 zip -r openssh-7.4p1.zip openssh-7.4p1 的详细解读如下:

  • zip: 用于创建和管理zip格式的压缩文件的命令。
  • -r: 选项表示递归地压缩目录及其子目录中的所有文件。
  • openssh-7.4p1.zip: 指定要创建的压缩文件名为openssh-7.4p1.zip
  • openssh-7.4p1: 指定要压缩的目录或文件为openssh-7.4p1

因此,该命令的作用是将目录openssh-7.4p1(包括其子目录中的所有文件)递归地压缩到名为openssh-7.4p1.zip的压缩文件中。
压缩文件将包含openssh-7.4p1目录下的所有文件和子目录,保持原始目录结构。

# unzip openssh-7.4p1.zip  -d test/

Archive:  openssh-7.4p1.zip
   creating: test/openssh-7.4p1/
  inflating: test/openssh-7.4p1/openssh-7.4p1-23.el7_9.x86_64.rpm
  inflating: test/openssh-7.4p1/openssh-clients-7.4p1-23.el7_9.x86_64.rpm
  inflating: test/openssh-7.4p1/openssh-server-7.4p1-23.el7_9.x86_64.rpm

# ll test/
total 4
drwxr-xr-x 2 root root 4096 Sep  5 09:17 openssh-7.4p1
image.png
# unzip --help

UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
modifiers:
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -U  use escapes for all non-ASCII Unicode  -UU ignore any Unicode fields
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
  -O CHARSET  specify a character encoding for DOS, Windows and OS/2 archives
  -I CHARSET  specify a character encoding for UNIX and other archives

See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer

# unzip -l  openssh-7.4p1.zip

Archive:  openssh-7.4p1.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  09-05-2023 09:17   openssh-7.4p1/
   522276  08-08-2023 22:22   openssh-7.4p1/openssh-7.4p1-23.el7_9.x86_64.rpm
   670588  08-08-2023 22:22   openssh-7.4p1/openssh-clients-7.4p1-23.el7_9.x86_64.rpm
   470524  08-08-2023 22:23   openssh-7.4p1/openssh-server-7.4p1-23.el7_9.x86_64.rpm
---------                     -------
  1663388                     4 files

命令 unzip -l openssh-7.4p1.zip 的详细解读如下:

  • unzip: 用于解压缩zip格式的压缩文件的命令。
  • -l: 选项表示以列表形式显示压缩包中的文件列表。
  • openssh-7.4p1.zip: 指定要解压缩和查看的压缩文件为openssh-7.4p1.zip

因此,该命令的作用是以列表形式显示压缩包openssh-7.4p1.zip中的文件列表。命令的输出列出了压缩包中的每个文件的相关信息,包括文件名、长度、日期和时间等。
在这个例子中,压缩包中包含了4个文件,分别是:

  1. openssh-7.4p1/:一个目录,长度为0字节,日期和时间为09-05-2023 09:17。
  2. openssh-7.4p1/openssh-7.4p1-23.el7_9.x86_64.rpm:一个rpm文件,长度为522276字节,日期和时间为08-08-2023 22:22。
  3. openssh-7.4p1/openssh-clients-7.4p1-23.el7_9.x86_64.rpm:一个rpm文件,长度为670588字节,日期和时间为08-08-2023 22:22。
  4. openssh-7.4p1/openssh-server-7.4p1-23.el7_9.x86_64.rpm:一个rpm文件,长度为470524字节,日期和时间为08-08-2023 22:23。

总共压缩包中的文件占用了1663388字节。

相关文章

  • Linux内核开发环境配置

    Linux不同版本内核安装 查看Linux版本 查看内核版本 解压内核压缩包 Linux内核源码安装流程 VSCo...

  • Shell 命令之 unzip

    解压到当前目录 解压到指定目录 不覆盖已经存在的文件 强制覆盖已经存在的文件 查看压缩包中的文件列表 查看压缩包中...

  • Linux 使用 tar 命令压缩解压文件

    Linux 使用 tar 命令压缩解压文件 Linux 中常见的压缩包扩展名(包括但不限于): *.tar, *....

  • linux部署vue项目--nginx

    一、上传文件包 将压缩包dist.zip上传至linux系统下---如/home/server/dist 解压压缩...

  • Linux解压Windows包

    linux安装rarlinux 在windows中的压缩包上传至Linux中无法直接解压,需要安装unrar包 下...

  • [Linux] linux 命令相关与常见问题

    1:Linux 下解压.tar.gz 和.gz文件 2: linux 下 查看某进程然后杀掉 3:什么是Linux...

  • 解压缩文件

    1. zip linux中压缩文件 linux解压文件 2. tar linux中压缩文件tar -cvf /us...

  • linux常用命令

    linux下文件的解压命令 Linux下常见的压缩包格式有5种:zip tar.gz tar.bz2 tar.xz...

  • Linux 学习2

    Linux继续学习 1、打包、压缩管理 gzip 文件名 压缩文件 gzip -d 解压文件压缩包 tar -cz...

  • Linux文件管理

    Linux教程 Linux文件管理 本文介绍如何在Linux上创建文件、删除文件、复制文件、移动文件 使用touc...

网友评论

      本文标题:【Linux】Linux上如何在不解压的情况下查看压缩包中文件列

      本文链接:https://www.haomeiwen.com/subject/qxfdidtx.html