tar命令

tar 打包 

  tar命令的常用选项:

    打包的常用命令组合:zcvf

    解包的常用命令组合:zxvf或者xf

    查看压缩包内容的组合:tf

-z, –gzip 
  filter the archive through gzip 
  调用gzip来压缩归档文件,此时文件名最好为*.tar.gz

-j,–bzip2 
  filter archive through bzip2 
  调用bzip2来压缩归档文件,此时文件名最好为*.tar.bz2

-c, –create 
  create a new archive 
  创建新的归档文件

-v, –verbose 
  verbosely list files processed 
  在压缩/解压缩的过程中,将正在处理的文件名显示出来

-f, –file=ARCHIVE 
  use archive file or device ARCHIVE

 –exclude  排除   如果有多个需要排除的文件,可写成一个文件列表。 

  用X参数指定文件列表的形式排除不需要处理的文件或目录。-C,directory DIR 
  change to directory DIR 指定目录进行操作,如解压到指定目录。

-z,–gzip 

  • 通过gzip的支持进行解压缩

 

-j,–bzip2 
  通过bzip2的支持进行解压缩

 

-x,–extract,–get 
  xtract files from an archive 从归档文件中解出文件 。解打包或解压缩功能。

 

-C,–directory DIR 
  change to directory DIR 指定目录进行操作,如解压到指定目录

 

–exclude PATTERN 
  exclude files based upon PATTERN 排除不需要处理的文件或目录

 

-X,–exclude-from FILE 
  exclude files listed in FILE 
  指定文件列表的形式排除不需要处理的文件或目录

 

-t, –list 
  list the contents of an archive 
  查看压缩包的内容列表

-f, –file=ARCHIVE 
  use archive file or device ARCHIVE

 

 

补充:

-p, –preserve-permissions, –same-permissions 
  extract information about file permissions 
  保持文件属性

-P, –absolute-names 
  don’t strip leading ‘/’s from file names 
  打包带上”/”(很危险不要用)

posted @ 2018-07-08 21:14  狼的本性  阅读(222)  评论(0编辑  收藏  举报