In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Generally speaking, when we view the contents of an archive or compressed file, we need to decompress it first and then view it, which is more troublesome. Today I'll show you 10 different ways to easily view the contents of an archive or compressed file without extracting it.
It is technically impossible to view archived or compressed files without first decompressing them. The method described in this article decompresses these compressed files in a temporary directory/tmp in the background. After restarting the system, the contents of the/tmp directory will be emptied.
Before we go any further, here's an explanation of archiving and compressing files.
Archiving is the process of combining multiple files or folders into a single file. In this case, the generated file is not compressed. Compression is the result of combining multiple files or folders into one file and compressing it.
Archive files are not compressed files, but compressed files can be archive files. With these two concepts in mind, we formally describe how to view compressed file contents without decompression.
1. Using the Vim Editor
Vim is more than just an editor; it contains many other powerful features. The following command displays the contents of the compressed archive file directly:
$ vim test.tar.gz copy code
" tar.vim version v29" Browsing tarfile /home/alvin/test.tar.gz" Select a file with cursor and press ENTERtest/imag.jpgtest/file.pdftest/song.mp3test/
Not only that, but with Vim you can even browse archives directly, and if there are text files in them, you can also open them directly, which is very convenient.
If you need to open a text file, simply use the arrow keys to move the cursor to the front of the file and press ENTER to open it.
2. use the tar command
The tar command can be used not only to compress/decompress files, but also to view the contents of compressed packages without extracting tar files using the tar -tf command.
$ tar -tf test.tar test/test/image.jpgtest/file.pdftest/song.mp3
Alternatively, use the-v option to view detailed attributes of the archive, such as permissions, file owner, group, creation date, and so on.
$ tar -tvf test.tardrwxr-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. Use the rar command
Similarly, the rar v command can be used to view compressed package contents without extracting rar files.
$ rar v test.rarRAR 5.60 Copyright (c) 1993-2019 Alexander Roshal 24 Jun 2019Trial version Type 'rar -? ' for helpArchive: test.rarDetails: RAR 5Attributes 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. Use the command unrar
For the rar file above, you can also view the contents of the rar file using the unrar command with the l parameter.
$ unrar l test.rarUNRAR 5.60 freeware Copyright (c) 1993-2019 Alexander RoshalArchive: test.rarDetails: RAR 5Attributes 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. Use the zip command
Without extracting the zip file, you can view its contents using the zip -sf command.
$ zip -sf test.zipArchive contains:Life advices.jpgTotal 1 entries (597219 bytes)
6. Use the unzip command
Similar to unrar, use the unzip command with the-l argument to view the contents of the zip file.
$ unzip -l test.zipArchive: test.zipLength Date Time Name--------- ---------- ----- ----597219 2019-04-09 12:48 Life advices.jpg--------- -------597219 1 file
7. Use zipinfo command
To view the zip file contents, you can also use the zipinfo command.
$ zipinfo test.zip Archive: test.zipZip file size: 584859 bytes, number of entries: 1-rw-r--r-- 6.3 unx 597219 bx defN 18-Apr-09 12:48 Life advices.jpg1 file, 597219 bytes uncompressed, 584693 bytes compressed: 2.1%
8. Using the zcat command
Use the zcat command to view archive/compressed files.
$ zcat test.tar.gz
zcat has the same functionality as the gunzip -c command. So you can also use the following command:
$ gunzip -c test.tar.gz
9. Use the zless command
Use the zless command to view archived/compressed files.
$ zless test.tar.gz
Zless is similar to less in that it displays content page by page.
10. Use the less command
The less command, as you may know, allows you to view file contents interactively. Not only that, it can also be used to view the contents of archived/compressed files:
$ less test.tar.gz
summary
The above briefly introduces 10 different commands that allow you to view the contents of archived/compressed files without extracting them. If you are interested in some of these commands, you can delve into them yourself.
The above is all the content of this article, I hope to help everyone's study, but also hope that everyone a lot of support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.