How to compress a folder in Linux

tar -zcvf /home/xahot.tar.gz /xahot
tar -zcvf The full path of the filename generated after packaging The directory to be packaged


Example: After packaging the /xahot folder, a /home/xahot.tar.gz file is generated.

zip compression method:

Compress the current folder zip -r ./xahot.zip ./* -r means recursive
zip [parameter] [packaged file name] [packaged directory path]
decompress unzip xahot.zip does not explain
the basic usage of the linux zip command Yes:

linux zip command parameter list:

-a convert file to ASCII mode
-F try to repair damaged archive
-h show help interface
-m after compressing the file, delete the source file

-n specific strings do not compress files with specific suffix strings
-o set the latest change time of all files in the compressed file to the time of compression
-q quiet mode, do not display the execution process of the command during compression
- r Process all subdirectories and files in the specified directory together
-S include system files and hidden files (S is uppercase)
-t date Set the last modification date of the compressed file to the specified date, the date format is mmddyyyy

Example:

Package all files and folders in the /home/wwwroot/xahot/ directory into xahot.zip
zip in the current directory –q –r xahot.zip /home/wwwroot/xahot

The above command operation is to compress the files and folders of absolute addresses. The following gives the compressed relative path directory

For example, currently in the Bliux directory, the following operations can achieve the same effect as above.

zip –q –r xahot.zip xahot

For example, in my xahot directory now, the zip compression command I operate is

zip –q –r xahot.zip *

The above is done in quiet mode and includes system files and hidden files

unzip syntax:

unzip [-cflptuvz][-agCjLMnoqsVX][-P <password>][.zip file][file][-d <directory>][-x <file>] or unzip [-Z]

Supplementary note: unzip is a decompression program for .zip compressed files.

unzip parameter:

-c Display the decompressed result to the screen, converting characters appropriately.
-f Update existing files.
-l Display the files contained in the compressed file.
-p Similar to the -c parameter, it will display the decompressed result to the screen, but will not perform any conversion.
-t Check if the compressed file is correct.
-u is similar to the -f parameter, but in addition to updating existing files, also extracts other files in the compressed file into a directory.
-v Displays verbose information when executing yes.
-z Display only the remark text of the compressed file.
-a Perform necessary character conversions on text files.
-b Do not perform character conversion on text files.
-C File names in compressed files are case sensitive.
-j Do not process existing directory paths in compressed files.
-L Change all filenames in the archive to lowercase.
-M Send the output to the more program for processing.
-n Do not overwrite existing files when decompressing.
-o Overwrite the original file after unzip is executed without asking the user first.
-P <password> Use the password option for zip.
-q Executes without displaying any information.
-s Convert whitespace characters in filenames to underscore characters.
-V Preserves file version information for VMS.
-X When decompressing, save the original UID/GID of the file at the same time.
[.zip file] Specifies a .zip compressed file.
[files] Specifies which files in the .zip archive are to be processed.
-d <directory> Specifies the directory where the files are to be stored after decompression.
-x <file> Specifies which files in the .zip archive should not be processed.
-Z unzip -Z is equal to execute the zipinfo command

Example:

Unzip /home/wwwroot/xahot.zip to the current directory

unzip xahot.zip

If this prompt appears:

-bash: zip: command not found ZIP compression cannot be performed because ZIP is not installed, run this installation command to yum install zip

 

Please indicate the reprint: http://52kuaiyun.com/49.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325129351&siteId=291194637
Recommended