节庆美陈制作:Linux Unzip命令和zip命令

来源:百度文库 编辑:九乡新闻网 时间:2024/04/28 10:51:26

linux下解压zip文件

linux自带的unzip命令可以解压windows下的zip格式的压缩文件。

unzip命令

  语法:unzip [选项] 压缩文件名.zip

  各选项的含义分别为:

  -x 文件列表 解压缩文件,但不包括指定的file文件。

  -v 查看压缩文件目录,但不解压。

  -t 测试文件有无损坏,但不解压。

  -d 目录 把压缩文件解到指定目录下。

  -z 只显示压缩文件的注解。

  -n 不覆盖已经存在的文件。

  -o 覆盖已存在的文件且不要求用户确认。

  -j 不重建文档的目录结构,把所有文件解压到同一目录下。

  例1:将压缩文件text.zip在当前目录下解压缩。

  $ unzip text.zip

  例2:将压缩文件text.zip在指定目录/tmp下解压缩,如果已有相同的文件存在,要求unzip命令不覆盖原先的文件。

  $ unzip -n text.zip -d /tmp

  例3:查看压缩文件目录,但不解压。

  $ unzip -v text.zip  

linux   zip命令 的基本用法是:

zip [参数] [打包后的文件名] [打包的目录路径]

  linux   zip命令 参数列表:

      -a     将文件转成ASCII模式
      -F     尝试修复损坏的压缩文件    
      -h     显示帮助界面
      -m     将文件压缩之后,删除源文件

      -n 特定字符串    不压缩具有特定字尾字符串的文件
      -o     将压缩文件内的所有文件的最新变动时间设为压缩时候的时间
      -q     安静模式,在压缩的时候不显示指令的执行过程
      -r     将指定的目录下的所有子目录以及文件一起处理
      -S     包含系统文件和隐含文件(S是大写)
      -t 日期     把压缩文件的最后修改日期设为指定的日期,日期格式为mmddyyyy

举例:

将/home/Blinux /html/ 这个目录下所有文件和文件夹打包为当前目录下的html.zip

zip –q –r   html.zip /home/Blinux /html

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

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

zip –q –r html.zip html

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

zip –q –r html.zip *

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

以下是我在SSH下的帮助,供大家参考:

Copyright (C) 1990-2005 Info-ZIP
Type 'zip "-L"' for software license.
Zip 2.31 (March 8th 2005). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -R   PKZIP recursion (see manual)
  -e   encrypt                      -n   don't compress these suffixes