Linux命令查看压缩包文件目录

您所在的位置:网站首页 linux显示当前目录列表 Linux命令查看压缩包文件目录

Linux命令查看压缩包文件目录

2024-07-02 20:25| 来源: 网络整理| 查看: 265

1.使用 Vim 编辑器

Vim 不仅仅是编辑器,它还包含其他许多强大的功能。下面的命令将直接显示压缩归档文件的内容:

$ vim test.tar.gz " tar.vim version v29 " Browsing tarfile /home/alvin/test.tar.gz " Select a file with cursor and press ENTER test/imag.jpg test/file.pdf test/song.mp3 test/

不仅如此,使用 Vim 你甚至可以直接浏览归档文件,若其中有文本文件,你还可以直接 打开它,非常方便。 如果需要打开文本文件,只需使用箭头键将光标移到文件前面,然后按 _ENTER_ 键即可打开

2.使用 tar 命令

tar 命令不仅仅可以用于压缩/解压文件,还可以在不提取 tar 文件的情况下使用 tar -tf 命令查看压缩包内容。

$ tar -tf test.tar test/ test/image.jpg test/file.pdf test/song.mp3

或者,使用 -v 选项查看归档文件的详细属性,例如权限、文件所有者、组、创建日期等。

$ tar -tvf test.tar drwxr-xr-x alvin/users 0 2019-07-02 19:30 test/ -rw-r--r-- alvin/users 53632 2019-06-29 15:57 test/image.jpg -rw-r--r-- alvin/users 156831 2019-06-04 12:37 test/file.pdf -rw-r--r-- alvin/users 9702219 2019-04-25 20:35 test/song.mp3 3.使用 rar 命令

同样地,在不提取 rar 文件的情况下可以使用 rar v 命令查看压缩包内容。

$ rar v test.rar RAR 5.60 Copyright (c) 1993-2019 Alexander Roshal 24 Jun 2019 Trial version Type 'rar -?' for help Archive: test.rar Details: RAR 5 Attributes Size Packed Ratio Date Time Checksum Name ----------- --------- -------- ----- ---------- ----- -------- ---- -rw-r--r-- 53632 52166 97% 2019-06-29 15:57 70260AC4 test/image.jpg -rw-r--r-- 156831 139094 88% 2019-06-04 12:37 C66C545E test/file.pdf -rw-r--r-- 9702219 9658527 99% 2019-04-25 20:35 DD875AC4 test/song.mp3 ----------- --------- -------- ----- ---------- ----- -------- ---- 9912682 9849787 99% 3 4.使用 unrar 命令

对于上面的 rar 文件,你也可以使用带有 l 参数的 unrar 命令查看 rar 文件的内容。

$ unrar l test.rar UNRAR 5.60 freeware Copyright (c) 1993-2019 Alexander Roshal Archive: test.rar Details: RAR 5 Attributes Size Date Time Name ----------- --------- ---------- ----- ---- -rw-r--r-- 53632 2019-06-29 15:57 test/image.jpg -rw-r--r-- 156831 2019-06-04 12:37 test/file.pdf -rw-r--r-- 9702219 2019-04-25 20:35 test/song.mp3 ----------- --------- ---------- ----- ---- 9912682 3 5.使用 zip 命令

在不提取 zip 文件的情况下可以使用 zip -sf 命令查看其内容。

$ zip -sf test.zip Archive contains: Life advices.jpg Total 1 entries (597219 bytes) 6.使用 unzip 命令

与 unrar 差不多,使用 -l 参数的 unzip 命令来查看 zip 文件的内容。

$ unzip -l test.zip Archive: test.zip Length Date Time Name --------- ---------- ----- ---- 597219 2019-04-09 12:48 Life advices.jpg --------- ------- 597219 1 file 7.使用 zipinfo 命令

查看 zip 文件内容,你还可以使用 zipinfo 命令。

$ zipinfo test.zip Archive: test.zip Zip file size: 584859 bytes, number of entries: 1 -rw-r--r-- 6.3 unx 597219 bx defN 18-Apr-09 12:48 Life advices.jpg 1 file, 597219 bytes uncompressed, 584693 bytes compressed: 2.1% 8.使用 zcat 命令

使用 zcat 命令查看归档/压缩文件。

$ zcat test.tar.gz

zcat 与 gunzip -c 命令功能相同。因此,你还可以用下面的命令:

$ gunzip -c test.tar.gz 9.使用 zless 命令

使用 zless 命令查看归档/压缩文件。

$ zless test.tar.gz

zless 类似于 less ,它可以逐页显示内容。

10.使用 less 命令

less 命令大家都可能有所了解了,它能以交互的方式查看文件内容。不仅如此,它还可以用来查看归档/压缩文件的内容:

$ less test.tar.gz

原文:https://zhuanlan.zhihu.com/p/91593509



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3