In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the various variants of the zip command for compressing files on Linux. It is very detailed and has certain reference value. Friends who are interested must read it!
Basic zip command
First, let's take a look at the basic zip commands. It uses basically the same compression algorithm as gzip, but with some important differences. On the one hand, the gzip command is only used to compress a single file, while zip can either compress a file or combine multiple files together to form an archive. In addition, the gzip command is "in-place" compression. In other words, it leaves only one compressed file, but the original file is gone. This is a working example of gzip:
$gzip onefile$ ls-1 shs shs 10514 Jan 15 13:13 onefile.gz
And below is zip. Note that this command requires a name for the compressed archive, where gzip (after the compression operation) uses only the original file name and adds the .gz extension.
$zip twofiles.zip file* adding: file1 (deflated 82%) adding: file2 (deflated 82%) $ls-1 shs shs 58021 Jan 15 13:25 file1-rw-rw-r-- 1 shs shs 58933 Jan 15 13:34 file2-rw-rw-r-- 1 shs shs 21289 Jan 15 13:35 twofiles.zip
Notice that the original file is still in the same place.
The amount of disk space saved (that is, the degree of compression obtained) will depend on the contents of each file. The changes in the following example are significant.
Zip mybin.zip ~ / bin/* adding: bin/1 (deflated 26%) adding: bin/append (deflated 64%) adding: bin/BoD_meeting (deflated 18%) adding: bin/cpuhog1 (deflated 14%) adding: bin/cpuhog2 (stored 0%) adding: bin/ff (deflated 32%) adding: bin/file.0 (deflated 1%) adding: bin/loop (deflated 14%) adding: bin/notes (deflated 23%) adding: bin/patterns (stored 0%) adding: bin/runme ( Stored 0%) adding: bin/tryme (deflated 13%) adding: bin/tt (deflated 6%) unzip command
The unzip command will restore the contents from a zip file, and, as you might expect, the original zip file will remain there, while a similar gunzip command will retain only the uncompressed files.
$unzip twofiles.zipArchive: twofiles.zip inflating: file1 inflating: file2 $ls-Lmuri RWMI RWML-1 shs shs 58021 Jan 15 13:25 file1-rw-rw-r-- 1 shs shs 58933 Jan 15 13:34 file2-rw-rw-r-- 1 shs shs 21289 Jan 15 13:35 twofiles.zipzipcloak command
The zipcloak command encrypts a zip file, prompts you to enter your password twice (to make sure you don't have fat fingers), and then stores the file in place. As you can imagine, the file size will be different from the original file.
$zipcloak twofiles.zipEnter password:Verify password:encrypting: file1encrypting: file2 $ls-ltotal 204MurRWMurRWMurRWLLY-1 shs shs 58021 Jan 15 13:25 file1-rw-rw-r-- 1 shs shs 58933 Jan 15 13:34 file2-rw-rw-r-- 1 shs shs 21313 Jan 15 13:46 twofiles.zip comments
Next, edit the file you just created and insert the comment above the (comment above this line) line. Then use a zipnote command like this to add comments:
$zipnote-w twofiles.zip < commentszipsplit command
When the archive is too large, you can use the zipsplit command to break down a zip archive into multiple zip archives so that you can put one of them on a small USB drive. The easiest way seems to be to specify a maximum size for each part of the compressed file, which must be large enough to accommodate the largest contained file.
Zipsplit-n 12000 twofiles.zip2 zip files will be made creating: twofile1.zipcreating: twofile2.zip$ ls twofile*.zip-rw-rw-r-- 1 shs shs 10697 Jan 15 14:52 twofile1.zip-rw-rw-r-- 1 shs shs 10702 Jan 15 14:52 twofile2.zip-rw-rw-r-- 1 shs shs 21377 Jan 15 14:27 twofiles.zip
Notice how the extracted file is named twofile1 and twofile2 in turn.
The above is all the content of the article "what are the various variants of the zip command to compress files on Linux?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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: 238
*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.