文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>tar

tar

时间:2006-10-05  来源:anima

tar

GNU“tar”将许多文件保存到一个磁带或磁盘归档文件中,
并可以从归档文件中恢复各个文件。

用法:tar [选项]... [文件]...

示例:
  tar -cf archive.tar foo bar  # 从文件 foo 和 bar 创建归档文件 archive.tar。
  tar -tvf archive.tar         # 详细列举归档文件 archive.tar 中的所有文件。
  tar -xf archive.tar          # 解析归档文件 archive.tar 中的所有文件。

如果长选项表明参数是必需的,那么对等价的短选项
来说它同样是必需的。对可选的参数来说也类似。

主要操作模式:
  -t, --list              列出归档文件内容目录
  -x, --extract, --get    从归档文件中解析文件
  -c, --create            创建新的归档文件
  -d, --diff, --compare   找出归档文件和文件系统的不同之处
  -r, --append            将文件附加到归档文件之后
  -u, --update            只附加比归档中新的文件
  -A, --catenate          将 tar 文件附加到归档文件之后
      --concatenate       与 -A 相同
      --delete            从归档文件中删除 (不能在磁带上!)

Operation modifiers:
  -W, --verify               attempt to verify the archive after writing it
      --remove-files         remove files after adding them to the archive
  -k, --keep-old-files       don't replace existing files when extracting
      --keep-newer-files     don't replace existing files that are newer
                             than their archive copies
      --overwrite            overwrite existing files when extracting
      --no-overwrite-dir     preserve metadata of existing directories
  -U, --unlink-first         remove each file prior to extracting over it
      --recursive-unlink     empty hierarchies prior to extracting directory
  -S, --sparse               handle sparse files efficiently
  -O, --to-stdout            extract files to standard output
  -G, --incremental          handle old GNU-format incremental backup
  -g, --listed-incremental=FILE
                             handle new GNU-format incremental backup
      --ignore-failed-read   do not exit with nonzero on unreadable files
      --occurrence[=NUM]     process only the NUMth occurrence of each file in
                             the archive. This option is valid only in
                             conjunction with one of the subcommands --delete,
                             --diff, --extract or --list and when a list of
                             files is given either on the command line or
                             via -T option.
                             NUM defaults to 1.

处理文件属性:
      --owner=NAME             将被添加的文件所有者设置为 NAME
      --group=NAME             将被添加的文件所属的组设置为 NAME
      --mode=CHANGES           将被添加的文件的属性设置为 CHANGES
      --atime-preserve         不要改变输出文件的访问时间
  -m, --modification-time      不要解析文件的修改时间
      --same-owner             试图以相同的所有权解析文件
      --no-same-owner          以您自己的身份解析文件
      --numeric-owner          总是用编号作为用户/组的名字
  -p, --same-permissions       解析许可权限信息
      --no-same-permissions    不要解析许可权限信息
      --preserve-permissions   与 -p 相同
  -s, --same-order             对要解析的名称进行排序以便与归档匹配
      --preserve-order         与 -s 相同
      --preserve               与 -p 和 -s 都相同

Device selection and switching:
  -f, --file=ARCHIVE             use archive file or device ARCHIVE
      --force-local              archive file is local even if has a colon
      --rmt-command=COMMAND      use given rmt COMMAND instead of /etc/rmt
      --rsh-command=COMMAND      use remote COMMAND instead of rsh
  -[0-7][lmh]                    specify drive and density
  -M, --multi-volume             create/list/extract multi-volume archive
  -L, --tape-length=NUM          change tape after writing NUM x 1024 bytes
  -F, --info-script=FILE         run script at end of each tape (implies -M)
      --new-volume-script=FILE   same as -F FILE
      --volno-file=FILE          use/update the volume number in FILE

设备分块:
  -b, --blocking-factor=BLOCKS   每个记录 BLOCKS x 512 个字节
      --record-size=SIZE         每个记录 SIZE 个字节,512 的倍数
  -i, --ignore-zeros             忽略归档中全为零的块 (标示文件结束)
  -B, --read-full-records        当我们读入时重新分块 (为 4.2BSD 管道提供)

Archive format selection:
      --format=FMTNAME               create archive of the given format.
                                     FMTNAME is one of the following:
                                     v7        old V7 tar format
                                     oldgnu    GNU format as per tar <= 1.12
                                     gnu       GNU tar 1.13 format
                                     ustar     POSIX 1003.1-1988 (ustar) format
                                     posix     POSIX 1003.1-2001 (pax) format
      --old-archive, --portability   same as --format=v7
      --posix                        same as --format=posix
  --pax-option keyword[[:]=value][,keyword[[:]=value], ...]
                                     control pax keywords
  -V, --label=NAME                   create archive with volume name NAME
              PATTERN                at list/extract time, a globbing PATTERN
  -j, --bzip2                        filter the archive through bzip2
  -z, --gzip, --ungzip               filter the archive through gzip
  -Z, --compress, --uncompress       filter the archive through compress
      --use-compress-program=PROG    filter through PROG (must accept -d)

Local file selection:
  -C, --directory=DIR          change to directory DIR
  -T, --files-from=NAME        get names to extract or create from file NAME
      --null                   -T reads null-terminated names, disable -C
      --exclude=PATTERN        exclude files, given as a PATTERN
  -X, --exclude-from=FILE      exclude patterns listed in FILE
      --anchored               exclude patterns match file name start (default)
      --no-anchored            exclude patterns match after any /
      --ignore-case            exclusion ignores case
      --no-ignore-case         exclusion is case sensitive (default)
      --wildcards              exclude patterns use wildcards (default)
      --no-wildcards           exclude patterns are plain strings
      --wildcards-match-slash  exclude pattern wildcards match '/' (default)
      --no-wildcards-match-slash exclude pattern wildcards do not match '/'
  -P, --absolute-names         don't strip leading `/'s from file names
  -h, --dereference            dump instead the files symlinks point to
      --no-recursion           avoid descending automatically in directories
  -l, --one-file-system        stay in local file system when creating archive
  -K, --starting-file=NAME     begin at file NAME in the archive
      --strip-path=NUM         strip NUM leading components from file names
                               before extraction
  -N, --newer=DATE-OR-FILE     only store files newer than DATE-OR-FILE
      --newer-mtime=DATE       compare date and time when data changed only
      --after-date=DATE        same as -N
      --backup[=CONTROL]       在删除前备份,选择版本控制
      --suffix=SUFFIX          在删除前备份,覆盖常用后缀

Informative output:
      --help            print this help, then exit
      --version         print tar program version number, then exit
  -v, --verbose         verbosely list files processed
      --checkpoint      print directory names while reading the archive
      --check-links     print a message if not all links are dumped
      --totals          print total bytes written while creating archive
      --index-file=FILE send verbose output to FILE
      --utc             print file modification dates in UTC
  -R, --block-number    show block number within archive with each message
  -w, --interactive     ask for confirmation for every action
      --confirmation    same as -w

Compatibility options:
  -o                                 when creating, same as --old-archive
                                     when extracting, same as --no-same-owner

除非以 --suffix 或 SIMPLE_BACKUP_SUFFIX 设置备份后缀,否则备份后缀就是“~”。
可以用 --backup 或 VERSION_CONTROL 设置版本控制,可能的值为:

  t, numbered     进行编号备份
  nil, existing   如果编号备份存在则进行编号备份,否则进行简单备份
  never, simple   总是使用简单备份

ARCHIVE may be FILE, HOST:FILE or USER@HOST:FILE; DATE may be a textual date
or a file name starting with `/' or `.', in which case the file's date is used.
*This* `tar' defaults to `--format=gnu -f- -b20'.

Report bugs to <[email protected]>.


TAR(1)                               tar                               TAR(1)

NAME
       tar - The GNU version of the tar archiving utility

SYNOPSIS
       tar <operation> [options]

       Operations:
       [-]A --catenate --concatenate
       [-]c --create
       [-]d --diff --compare
       [-]r --append
       [-]t --list
       [-]u --update
       [-]x --extract --get
       --delete

       Common Options:
       -C, --directory DIR
       -f, --file F
       -j, --bzip2
       -p, --preserve-permissions
       -v, --verbose
       -z, --gzip

       All Options:
       [  --atime-preserve  ]  [ -b, --blocking-factor N ] [ -B, --read-full-
       records ] [ --backup BACKUP-TYPE ] [ --block-compress ] [ -C, --direc-
       tory  DIR  ]  [  --check-links  ] [ --checkpoint ] [ -f, --file [HOST-
       NAME:]F ] [ -F, --info-script F --new-volume-script  F  ]  [  --force-
       local    ]  [  --format  FORMAT ] [ -g, --listed-incremental F ] [ -G,
       --incremental ] [ --group GROUP ] [ -h, --dereference ] [ --help  ]  [
       -i,  --ignore-zeros  ]  [  --ignore-case  ] [ --ignore-failed-read ] [
       --index-file FILE ] [ -j, --bzip2 ] [ -k,  --keep-old-files  ]  [  -K,
       --starting-file F ] [ --keep-newer-files ] [ -l, --one-file-system ] [
       -L, --tape-length N ] [  -m,  --touch,  --modification-time  ]  [  -M,
       --multi-volume  ]  [  --mode  PERMISSIONS  ]  [ -N, --after-date DATE,
       --newer DATE ] [ --newer-mtime DATE ] [ --no-anchored ] [ --no-ignore-
       case ] [ --no-recursion ] [ --no-same-permissions ] [ --no-wildcards ]
       [ --no-wildcards-match-slash ] [ --null     ] [  --numeric-owner  ]  [
       -o,  --old-archive, --portability, --no-same-owner ] [ -O, --to-stdout
       ] [ --occurrence NUM ] [ --overwrite ] [ --overwrite-dir ]  [  --owner
       USER  ]  [  -p,  --same-permissions,  --preserve-permissions  ]  [ -P,
       --absolute-names ] [ --pax-option KEYWORD-LIST ] [ --posix ] [  --pre-
       serve  ] [ -R, --block-number ] [ --record-size SIZE ] [ --recursion ]
       [ --recursive-unlink ] [ --remove-files ]  [  --rmt-command  CMD  ]  [
       --rsh-command  CMD  ]  [  -s,  --same-order,  --preserve-order ] [ -S,
       --sparse ] [ --same-owner ] [ --show-defaults ] [  --show-omitted-dirs
       ]  [  --strip-components  NUMBER, --strip-path NUMBER (1) ] [ --suffix
       SUFFIX ] [ -T, --files-from F ] [ --totals   ] [ -U, --unlink-first  ]
       [  --use-compress-program  PROG  ]  [  --utc ] [ -v, --verbose ] [ -V,
       --label NAME ] [ --version  ] [ --volno-file F ] [ -w,  --interactive,
       --confirmation ] [ -W, --verify ] [ --wildcards ] [ --wildcards-match-
       slash ] [ --exclude PATTERN ] [ -X, --exclude-from FILE ] [ -Z, --com-
       press, --uncompress ] [ -z, --gzip, --gunzip, --ungzip ] [ -[0-7][lmh]
       ]

       (1) tar-1.14 uses --strip-path, tar-1.14.90+ uses --strip-components

DESCRIPTION
       This manual page documents the GNU version of tar, an  archiving  pro-
       gram designed to store and extract files from an archive file known as
       a tarfile.  A tarfile may be made on a tape drive, however, it is also
       common to write a tarfile to a normal file.  The first argument to tar
       must be one of the options Acdrtux, followed  by  any  optional  func-
       tions.   The  final  arguments  to  tar  are the names of the files or
       directories which should be archived.  The use  of  a  directory  name
       always implies that the subdirectories below should be included in the
       archive.

EXAMPLES
       tar -xvf foo.tar
              verbosely extract foo.tar

       tar -xzf foo.tar.gz
              extract gzipped foo.tar.gz

       tar -cjf foo.tar.bz2 bar/
              create  bzipped  tar  archive  of  the  directory  bar   called
              foo.tar.bz2

       tar -xjf foo.tar.bz2 -C bar/
              extract bzipped foo.tar.bz2 after changing directory to bar

       tar -xzf foo.tar.gz blah.txt
              extract the file blah.txt from foo.tar.bz2

FUNCTION LETTERS
       One of the following options must be used:

       -A, --catenate, --concatenate
              append tar files to an archive

       -c, --create
              create a new archive

       -d, --diff, --compare
              find differences between archive and file system

       -r, --append
              append files to the end of an archive

       -t, --list
              list the contents of an archive

       -u, --update
              only append files that are newer than the existing in archive

       -x, --extract, --get
              extract files from an archive

       --delete
              delete from the archive (not for use on mag tapes!)

COMMON OPTIONS
       -C, --directory DIR
              change to directory DIR

       -f, --file [HOSTNAME:]F
              use  archive  file or device F (default "-", meaning stdin/std-
              out)

       -j, --bzip2
              filter archive through bzip2, use to decompress .bz2 files

       -p, --preserve-permissions
              extract all protection information

       -v, --verbose
              verbosely list files processed

       -z, --gzip, --ungzip
              filter the archive through gzip

ALL OPTIONS
       --atime-preserve
              don’t change access times on dumped files

       -b, --blocking-factor N
              block size of Nx512 bytes (default N=20)

       -B, --read-full-blocks
              reblock as we read (for reading 4.2BSD pipes)

       --backup BACKUP-TYPE
              backup files instead of deleting them using BACKUP-TYPE  simple
              or numbered

       --block-compress
              block the output of compression program for tapes

       -C, --directory DIR
              change to directory DIR

       --check-links
              warn if number of hard links to the file on the filesystem mis-
              match the number of links recorded in the archive

       --checkpoint
              print directory names while reading the archive

       -f, --file [HOSTNAME:]F
              use archive file or device F (default "-",  meaning  stdin/std-
              out)

       -F, --info-script F --new-volume-script F
              run script at end of each tape (implies --multi-volume)

       --force-local
              archive file is local even if has a colon

       --format FORMAT
              selects output archive format
              v7 - Unix V7
              oldgnu - GNU tar <=1.12
              gnu - GNU tar 1.13
              ustar - POSIX.1-1988
              posix - POSIX.1-2001

       -g, --listed-incremental F
              create/list/extract new GNU-format incremental backup

       -G, --incremental
              create/list/extract old GNU-format incremental backup

       -h, --dereference
              don’t dump symlinks; dump the files they point to

       --help like this manpage, but not as cool

       -i, --ignore-zeros
              ignore blocks of zeros in archive (normally mean EOF)

       --ignore-case
              ignore case when excluding files

       --ignore-failed-read
              don’t exit with non-zero status on unreadable files

       --index-file FILE
              send verbose output to FILE instead of stdout

       -j, --bzip2
              filter archive through bzip2, use to decompress .bz2 files

       -k, --keep-old-files
              keep existing files; don’t overwrite them from archive

       -K, --starting-file F
              begin at file F in the archive

       --keep-newer-files
              do not overwrite files which are newer than the archive

       -l, --one-file-system
              stay in local file system when creating an archive

       -L, --tape-length N
              change tapes after writing N*1024 bytes

       -m, --touch, --modification-time
              don’t extract file modified time

       -M, --multi-volume
              create/list/extract multi-volume archive

       --mode PERMISSIONS
              apply PERMISSIONS while adding files (see chmod(1))

       -N, --after-date DATE, --newer DATE
              only store files newer than DATE

       --newer-mtime DATE
              like --newer, but with a DATE

       --no-anchored
              match any subsequenceof the name’s components with --exclude

       --no-ignore-case
              use case-sensitive matching with --exclude

       --no-recursion
              don’t recurse into directories

       --no-same-permissions
              apply  user’s  umask  when extracting files instead of recorded
              permissions

       --no-wildcards
              don’t use wildcards with --exclude

       --no-wildcards-match-slash
              wildcards do not match slashes (/) with --exclude

       --null --files-from reads null-terminated names, disable --directory

       --numeric-owner
              always use numbers for user/group names

       -o, --old-archive, --portability
              like --format=v7; -o exhibits this behavior  when  creating  an
              archive (deprecated behavior)

       -o, --no-same-owner
              do  not  attempt  to  restore  ownership  when  extracting;  -o
              exhibits this behavior when extracting an archive

       -O, --to-stdout
              extract files to standard output

       --occurrence NUM
              process only NUM occurrences of  each  named  file;  used  with
              --delete, --diff, --extract, or --list

       --overwrite
              overwrite existing files and directory metadata when extracting

       --overwrite-dir
              overwrite directory metadata when extracting

       --owner USER
              change owner of extraced files to USER

       -p, --same-permissions, --preserve-permissions
              extract all protection information

       -P, --absolute-names
              don’t strip leading ‘/’s from file names

       --pax-option KEYWORD-LIST
              used only with POSIX.1-2001 archives to modify the way tar han-
              dles extended header keywords

       --posix
              like --format=posix

       --preserve
              like --preserve-permissions --same-order

       -R, --record-number
              show record number within archive with each message

       --record-size SIZE
              use SIZE bytes per record when accessing archives

       --recursion
              recurse into directories

       --recursive-unlink
              remove  existing  directories  before extracting directories of
              the same name

       --remove-files
              remove files after adding them to the archive

       --rmt-command CMD
              use CMD instead of the default /usr/sbin/rmt

       --rsh-command CMD
              use remote CMD instead of rsh(1)

       -s, --same-order, --preserve-order
              list of names to extract is sorted to match archive

       -S, --sparse
              handle sparse files efficiently

       --same-owner
              create extracted files with the same ownership

       --show-defaults
              display the default options used by tar

       --show-omitted-dirs
              print directories tar skips while operating on an archive

       --strip-components NUMBER, --strip-path NUMBER
              strip NUMBER of  leading  components  from  file  names  before
              extraction

              (1)  tar-1.14 uses --strip-path, tar-1.14.90+ uses --strip-com-
              ponents

       --suffix SUFFIX
              use SUFFIX instead of default ’~’ when backing up files

       -T, --files-from F
              get names to extract or create from file F

       --totals
              print total bytes written with --create

       -U, --unlink-first
              remove existing files before extracting files of the same name

       --use-compress-program PROG
              access the archive through PROG which is generally  a  compres-
              sion program

       --utc  display file modification dates in UTC

       -v, --verbose
              verbosely list files processed

       -V, --label NAME
              create archive with volume name NAME

       --version
              print tar program version number

       --volno-file F
              keep  track of which volume of a multi-volume archive its work-
              ing in FILE; used with --multi-volume

       -w, --interactive, --confirmation
              ask for confirmation for every action

       -W, --verify
              attempt to verify the archive after writing it

       --wildcards
              use wildcards with --exclude

       --wildcards-match-slash
              wildcards match slashes (/) with --exclude

       --exclude PATTERN
              exclude files based upon PATTERN

       -X, --exclude-from FILE
              exclude files listed in FILE

       -Z, --compress, --uncompress
              filter the archive through compress

       -z, --gzip, --gunzip, --ungzip
              filter the archive through gzip

       --use-compress-program PROG
              filter the archive through PROG (which must accept -d)

       -[0-7][lmh]
              specify drive and density

BUGS
       The GNU folks, in general, abhor man pages, and create info  documents
       instead.   The  maintainer of tar falls into this category.  Thus this
       man page may not be complete, nor current, and was included in the Red
       Hat  CVS tree because man is a great tool :).  This man page was first
       taken from Debian Linux and has since been lovingly updated here.

REPORTING BUGS
       Please report bugs via https://bugzilla.redhat.com

SEE ALSO
       The full documentation for tar is maintained as a Texinfo manual.   If
       the  info  and  tar  programs are properly installed at your site, the
       command

              info tar

       should give you access to the complete manual.

AUTHORS
       Debian Linux http://www.debian.org/
       Mike Frysinger <[email protected]>

GNU                                Oct 2004                            TAR(1)
相关阅读 更多 +
排行榜 更多 +
快读全本小说阅读器

快读全本小说阅读器

浏览阅读 下载
巴士大亨公司模拟

巴士大亨公司模拟

模拟经营 下载
国产

国产

音乐节奏 下载