In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Zip
Zip is one of the most general file compression methods, which is used in unix, msdos, windows, OS and other systems. If the bzip 2 library is included when compiling zip, zip now also supports bzip 2 compression. When files larger than 4GB are added to the archive, zip automatically uses the Zip 64 extension, and the archive containing Zip 64 entries is updated (if the resulting archive still requires Zip 64), the size of the archive will exceed 4GB, or when the number of entries in the archive exceeds 64K. Zip 64 is also used for files transferred from standard input because the size of these files is not known in advance, but the option fz can be used to force zip to create PKZIP 2-compatible files (as long as no Zip 64 extension is required). You must use PKZIP4.5 compatibility to extract files, such as version 6.0 or later, before you can extract files using the Zip 64 extension.
The zip program places one or more compressed files in a compressed archive with information about the file (name, path, date, time last modified, protection, and check information to verify file integrity). You can package the entire directory structure into a zip archive with one command. For text files, a compression ratio of 2:1 and 3:1 is common. Zip has only one compression method (deflation) and can store files without compression. (if bzip 2 support is added, zip can also use bzip 2 compression, but these entries require a reasonable modern decompression to extract. When bzip 2 compression is selected, it replaces deflation with the default method.) Zip automatically selects two better files for each file to be compressed (deflation or storage, or bzip2 or Store if you choose bzip2).
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Zip [options] zipfile list
2. List of options
Option
Description
-? | |-h |-- help |
Help information
-H3 |-- more-help
Displays extended help, including more options for command line formatting, pattern matching, and more blurring.
-V |-- version
Display command version information
-a |-- ascii
Convert EBCDIC files used by the system to ascii
-A |-- adjust-sfx
Adjust the self-extracting executable file. A self-extracting executable archive is created by placing a SFX stub in front of an existing archive. The-An option tells zip to adjust the item offset stored in the archive to take into account these "prologue" data.
-b path |-- temp-path path
Use the specified path for temporary zip archiving
-B |-- binary
Use binary format, which defaults to text format
-c |-- entry-comments
Add comment information to the compressed file
-d |-- delete
Removes the specified file from the compressed file
-db |-- display-bytes
Displays the running byte count, the compressed bytes and the bytes to run.
-dc |-- display-counts
Displays the run count of compressed entries and the entries to be run
-dd |-- display-dots
Displays dots when each entry is zipped (except on a port with its own progress indicator). See the setting point size below-DS. By default, there is a point for every 10 MB input file processed. The-v option also shows points (the rate used to be much higher than this, but now-v also defaults to 10 MB), which is also controlled by-ds.
-dg |-- display-globaldots
Displays the progress point of the archive instead of displaying the progress point for each file.
-ds size |-- dot-size size
Sets the number of input files processed for each point displayed. The size is in nm format, where n is a number and m is a multiplier. At present, m can be k (KB), m (MB), g (GB), or t (TB), so if n is 100 KB, then the size will be 100 k. The default value is 10 MB.
-du |-- display-usize
Displays the uncompressed size of each entry.
-dv |-- display-volume
Displays the volume (disk) number of each entry being read, if you read the existing archive and write it to
-D |-- no-dir-entries
Do not create entries for directories in the zip archive.
-DF |-- difference-archive
Create an archive file that contains all new and changed files since the original archive was created.
-e |-- encrypt
Compressed file encryption
-f |-- freshen
Replace the old file in the compressed file, if the file does not exist, then the file will not be appended
-F |-- fix |-- FF |-- fixfix
Try to repair a corrupted compressed file
-FI |-- fifo
Usually zip skips reading any FIFO (named pipes) encountered, because if the FIFO is not fed, the zip hangs.
-FS |-- filesync
Synchronize the archived contents with the files on the operating system
-g |-- grow
Append the file to the end of the existing compressed file
-I |-- include
Contains only the specified files
-j |-- junk-paths
When compressing, ignore the path in the file name and save only the file name and content
-J |-- junk-sfx
Remove any preset data from the archive
-I |-- include
Contains only the specified files
-la |-- log-append
Attach to an existing log file. The default value is override
-lf |-- logfile-path
Opens the log file on the given path. By default, any existing files in this location are overwritten
-li |-- log-info
Include information messages in the log, such as the name of the file being compressed. By default, only the command line, any warnings and errors, and the final state are included.
-L |-- license
Display the license for zip
-m |-- move
Moves the specified file to a compressed file
-MM |-- must-match
All input patterns must match at least one file, and all found input files must be readable.
-n |-- suffixes
Do not try to compress a file named with a given suffix.
-nw |-- no-wild
Do not perform internal wildcard processing.
-o |-- latest-time
Set the Last modified time of the zip archive to the latest (oldest) Last modified time found in the entry in the zip archive.
-O |-- output-file
Archive changes are processed as usual, but instead of updating the existing archive, the new archive is output to the output file.
-p |-- path
Use the relative file path as part of the file name stored in the archive
-P |-- password
Encrypt
-Q |-- quite
Silent mode, does not show the execution process
-r |-- recurse-paths
When compressing, recursively process the directory
-R |-- recurse-patterns
Recursively iterate through the directory structure, starting with the current directory.
-s |-- split-size
Enable create split archive and set split size
-sb |-- split-bell
If you split and use split pause mode, press the ringtone when zip pauses for each split target.
-sc |-- show-command
Displays the command line that starts zip that has been processed and exited
-sf |-- show-files
Show the file you want to manipulate, and then exit.
-so |-- show-options
Displays all available options supported by zip compiled on the current system
-sp |-- split-pause
If split is enabled with-s, split pause mode is enabled
-su |-- show-unicode
Like-sf, the unicode version of the path is also displayed if it exists
-sU |-- show-just-unicode
As with-sf, only the Unicode version of the path (if present) is displayed, otherwise the standard version of the path is displayed.
-sv |-- split-verbose
Enable a variety of detailed messages at split time, showing how the split is done.
-t mmddyyyy |-- from-date mmddyyyy
Do not operate on files modified before the specified date, where mm is the month (00-12), dd is the date of the month (01-31), and yyyy is the year.
-T |-- test
Test the integrity of the new zip file. If the check fails, the old zip file remains unchanged and the input file is not deleted (using the-m option).
-TT |-- unzip-command
When using the-T option, use the command cmd instead of "unzip-tqq" to test the archive.
-U |-- copy-entries
Copy entries from one archive to another.
-u |-- update
Update the file, if it does not exist, append it directly. Replace (update) an existing entry in the zip archive only if it has been modified more recently than the version in the zip archive.
-UN |-- unicode
Determine what zip should do with unicode filenames
-x |-- exclude
The specified file is not included in the compression
-y
Save symbolic links directly during compression
-v |-- verbose
Show execution process
-ws |-- wild-stop-dirs
Wildcards match only at the directory level.
-#
Adjusts the compression speed using the specified number #, where-0 indicates no compression (stores all files),-1 indicates the fastest compression speed (less compression), and-9 represents the slowest compression speed (best compression, ignoring the suffix list). The default compression level is-6
-@ |-- names-stdin
Get a list of input files from standard input. There is only one file name per line.
4. Pattern matching
? To match any single character
* to match any number of characters
[] matches any character within the range shown in parentheses (for example: [amurf], [0-9]).
5. Exit code
, normal, no errors.
2. Unexpected end of compressed file.
3. A common error in the zip file format was detected.
4, zip cannot allocate memory for one or more buffers during program initialization.
5. A serious error was detected in the zip file format.
6. The entry is too large to be processed (for example, the input file is larger than 2GB when you do not use Zip 64 or try to read an existing archive too large) or the entry is too large to be split with zip.
7, invalid comment format.
8, zip-T failed or insufficient memory.
9, the user uses Control-C (or similar) to abort zip prematurely.
10. Zip encountered an error while using temporary files.
11, read or find errors.
12. Zip has nothing to do.
13, missing or empty compressed file.
14, an error occurred while writing the file.
15, zip cannot create a file to write to.
16, bad command line arguments.
18, zip cannot open the specified file to read.
19, zip is compiled for options not supported in this system.
6. Example code
Create an archive stuff.zip (assuming it does not exist) and place all files in the current directory in compressed form. (the .zip suffix is automatically added unless the archive name already contains a dot; this allows you to specify other suffixes.)
Zip stuff *
Zip stuff. * *
Compress the entire directory. Create an archive foo.zip that contains all files and directories in the directory foo contained in the current directory.
Zip-r foo foo
You may want to create a zip archive that contains files in foo without recording the directory name foo. You can use the-j option to close the path, as shown in
Zip-j foo foo/*
If you lack disk space, you may not have enough space to save the original directory and the corresponding compressed archive files. In this case, you can use the-m option to create the archive step by step. If foo contains subdirectories Tom, Dick, and Harry. Where the first command creates the foo.zip and the next two commands are added to it. After each zip command is completed, the last created archive file is deleted, providing a workspace for the next zip command.
Zip-rm foo foo/tom
Zip-rm foo foo/dick
Zip-rm foo foo/harry
Use-s to set the split size and create a split archive. The size is optionally followed by one of k (KB), m (MB), g (Gb) or t (Tb). Create a split archive of the directory foo, with each partition no larger than 2GB. If the foo contains 5 GB of content, and the content is stored in a split archive uncompressed (to simplify this example), this creates three chunks, namely, 2GB's split.z01, 2GB's split.z02, and split.zip slightly higher than 1GB.
Zip-s 2g-r split.zip foo
Although zip does not update split archives, zip provides a new option-O (- Output-file), which allows you to update split files and save them in a new archive. The archive file is read, and even if split, the foo.c and bar.c files are added, and the result archive is written to outArchive.zip. If the inArchive.zip is split, the outArchive.zip defaults to the same split size. Note that outArchive.zip and any split files created with it are overwritten without warning. This situation may change in the future.
Zip inarchive.zip foo.c bar.c-out outarchive.zip
7. Examples
1) compress the file
[root@localhost weijie] # zip-r res. -I * .c / / compress all .c files in the current directory
Adding: 11.c (stored 0%)
Adding: 4.C (stored 0%)
Adding: 2.c (deflated 9%)
Adding: 3.c (stored 0%)
Adding: 5.c (deflated 13%)
[root@localhost weijie] # ls
11.c 1.c.gz 2.c 3.c 4.c 5.c 6.c ~ res.zip
2) add or delete contents to the compressed file
[root@localhost weijie] # zip res.zip-g 6.c/ / append 6.cc
Adding: 6.c ~ (stored 0%)
[root@localhost weijie] # zip res.zip-d 2.c / / Delete 2.c
Deleting: 2.c
3) set password during compression
[root@localhost weijie] # zip-er res. -I * .c / / set the password. You need to enter the password twice.
Enter password:
Verify password:
Adding: 11.c (stored 0%)
Adding: 4.C (stored 0%)
Adding: 2.c (deflated 9%)
Adding: 3.c (stored 0%)
Adding: 5.c (deflated 13%)
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.