zip command for packaging compressed files in Centos

The most common compressed files in linux are .tar.gz, .zip, and .gz. In linux, you have to get used to the days without .rar.
The following is a detailed explanation of the tar and zip commands.
tar -zcvf /home/files.tar.gz /files
tar -zcvf The full path of the file name generated after packaging is a directory example to be packaged
: after packaging the /files folder, a /home/files is generated .tar.gz file.

zip compression method:

Compress the current folder zip -r ./files.zip ./* -r means recursive
zip [parameter] [packaged file name] [packaged directory path]
decompress unzip files.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/files/ directory into files.zip in the current directory

zip –q –r files.zip /home/wwwroot/files

上面的命令操作是将绝对地址的文件及文件夹进行压缩.以下给出压缩相对路径目录

比如目前在Bliux这个目录下,执行以下操作可以达到以上同样的效果.

zip –q –r files.zip files

比如现在我的files目录下,我操作的zip压缩命令是

zip –q –r files.zip *

以上是在安静模式下进行的,而且包含系统文件和隐含文件


//////////////////////////////////////////////////////////
unzip语 法:

unzip [-cflptuvz][-agCjLMnoqsVX][-P <密码>][.zip文件][文件][-d <目 录>][-x <文件>] 或 unzip [-Z]

补充说明:unzip为.zip压缩文件的解压缩程序。

 

举例:

将/home/wwwroot/files.zip解压到当前目录

unzip files.zip

如果出现这个提示:
-bash: zip: command not found 不能执行ZIP压缩,是因为没有安装ZIP,
运行下这条安装命令即可 yum install zip

Guess you like

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