Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Methods of Compression and decompression of Files under Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "the compression and decompression methods of files under Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Gzip

Function description: decompress the file.

Grammar: gzip [- acfhlLnNqrtvV] [- s] [file.] Or gzip [- acfhlLnNqrtvV] [- s] [directory]

Note: gzip is a widely used decompression program, which is used to unzip files compressed by gzip, these compressed files default to the final extension ".gz". In fact, gzip is the hard connection of gzip, so whether it is compressed or decompressed, it can be done separately through the gzip instruction.

Parameters:

-an or-- ascii uses ASCII text mode.

-c or-- stdout or-- to-stdout outputs the decompressed file to a standard output device.

-f or-force forcibly unzip the compressed file, regardless of whether the file name or hard connection exists and whether the file is a symbolic link.

-h or-- help online help.

-l or-- list lists information about the compressed file.

-L or-- license displays version and copyright information.

When unzipping-n or-- no-name, if the compressed file contains a distant file name and timestamp, it will be ignored and not processed.

When-N or-- name unzips, if the compressed file contains the original file name and timestamp, it will be saved back to the unzipped file.

-Q or-- quiet does not display a warning message.

-r or-- recursive recursive processing, processing all files and subdirectories under the specified directory together.

-S or-- suffix changes the compressed suffix string.

-t or-- test tests whether the compressed file is correct.

-v or-- verbose shows the instruction execution process.

-V or-- version displays version information.

Example:

The code is as follows:

[root@localhost zhangy] # tar cf test.tar-R test # gzip cannot compress directories. Package first.

[root@localhost zhangy] # gzip test.tar # Compression

[root@localhost zhangy] # gzip-l test.tar.gz # View the contents of the package

[root@localhost zhangy] # gzip-dv test.tar.gz # decompress

Unzip

Function description: extract the zip file

Grammar: unzip [- cflptuvz] [- agCjLMnoqsVX] [- P] [.zip file] [file] [- d] [- x] or unzip [- Z]

Supplementary note: unzip is an unzipped program for .zip compressed files.

Parameters:

-c displays the unzipped results on the screen and converts the characters appropriately.

-f update existing files.

-l displays the files contained in the compressed file.

The-p parameter is similar to the-c parameter and displays the result of the decompression to the screen, but no conversion is performed.

-t check that the compressed file is correct.

The-u parameter is similar to the-f parameter, but in addition to updating existing files, other files in the compressed file are also unzipped to a directory.

-v displays detailed information when executing Yes.

-z displays only the remarks text of the compressed file.

-a make the necessary character conversion to the text file.

-b do not convert characters to text files.

-the file name in a compressed C file is case sensitive.

-j does not process the original directory path in the compressed file.

-L changes all file names in the compressed file to lowercase.

-M sends the output to the more program for processing.

-n do not overwrite the original file when unzipping.

-o you do not need to ask the user first, the original file will be overwritten after unzip execution.

-P uses the password option of zip.

-Q does not display any information when executed.

-s converts white space characters in the file name to underscore characters.

-V retains the file version information of VMS.

-X unzips the original UID/GID of the file at the same time.

[.zip file] specifies the .zip zip file.

[file] specifies which files in the .zip zip file are to be processed.

-d specifies the directory to store after the file is unzipped.

-x specifies which files in the .zip zip file should not be processed.

-Z unzip-Z equals to execute zipinfo instruction

Example:

The code is as follows:

[root@localhost a] # unzip-j myfile.zip # does not reconstruct the directory structure of the document, but decompresses all files to the same directory

Archive: myfile.zip

Inflating: install.log

Inflating: anaconda-ks.cfg

Inflating: install.log.syslog

The code is as follows:

[root@localhost a] # unzip-n text.zip-d / tmp # extract the compressed files to the specified directory without overwriting the existing files

The code is as follows:

[root@localhost a] # unzip-Z text.zip # View compressed file information without decompression

This is the end of the content of "the method of compressing and decompressing files under Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report