码迷,mamicode.com
首页 > 系统相关 > 详细

Linux命令:tar

时间:2019-03-20 10:28:04      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:输出   更新   rri   iss   click   log   sim   method   null   

文件打包命令,把一组文件或目录打到一个文件里。还可以选择是否压缩、哪种压缩。或者反之把它打包的文档还原并拆成一个一个的文档。

tar
-c: 建立压缩档案
-x:解压
-t:查看内容
-r:向压缩归档文件末尾追加文件
-u:更新原压缩包中的文件

这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。

-z:有gzip属性的
-j:有bz2属性的
-Z:有compress属性的
-v:显示所有过程
-O:将文件解开到标准输出

下面的参数-f是必须的

-f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。

# tar -cf all.tar *.jpg 
这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。 

# tar -rf all.tar *.gif 
这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。 

# tar -uf all.tar logo.gif 
这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。 

# tar -tf all.tar 
这条命令是列出all.tar包中所有文件,-t是列出文件的意思 

# tar -xf all.tar 
这条命令是解出all.tar包中所有文件,-x是解开的意思 

压缩
tar –cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg
tar –czf jpg.tar.gz *.jpg   //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz
tar –cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2
tar –cZf jpg.tar.Z *.jpg   //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z
rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux
zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux

解压
tar –xvf file.tar //解压 tar包
tar -xzvf file.tar.gz //解压tar.gz
tar -xjvf file.tar.bz2   //解压 tar.bz2
tar –xZvf file.tar.Z   //解压tar.Z
unrar e file.rar //解压rar
unzip file.zip //解压zip

总结
1、*.tar 用 tar –xvf 解压
2、*.gz 用 gzip -d或者gunzip 解压
3、*.tar.gz和*.tgz 用 tar –xzf 解压
4、*.bz2 用 bzip2 -d或者用bunzip2 解压
5、*.tar.bz2用tar –xjf 解压
6、*.Z 用 uncompress 解压
7、*.tar.Z 用tar –xZf 解压
8、*.rar 用 unrar e解压
9、*.zip 用 unzip 解压

 

 

帮助

tar --help

技术图片
  1 Usage: tar [OPTION...] [FILE]...
  2 GNU `tar saves many files together into a single tape or disk archive, and can
  3 restore individual files from the archive.
  4 
  5 Examples:
  6   tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
  7   tar -tvf archive.tar         # List all files in archive.tar verbosely.
  8   tar -xf archive.tar          # Extract all files from archive.tar.
  9 
 10  Main operation mode:
 11 
 12   -A, --catenate, --concatenate   append tar files to an archive
 13   -c, --create               create a new archive
 14   -d, --diff, --compare      find differences between archive and file system
 15       --delete               delete from the archive (not on mag tapes!)
 16   -r, --append               append files to the end of an archive
 17   -t, --list                 list the contents of an archive
 18       --test-label           test the archive volume label and exit
 19   -u, --update               only append files newer than copy in archive
 20   -x, --extract, --get       extract files from an archive
 21 
 22  Operation modifiers:
 23 
 24       --check-device         check device numbers when creating incremental
 25                              archives (default)
 26   -g, --listed-incremental=FILE   handle new GNU-format incremental backup
 27   -G, --incremental          handle old GNU-format incremental backup
 28       --ignore-failed-read   do not exit with nonzero on unreadable files
 29       --level=NUMBER         dump level for created listed-incremental archive
 30   -n, --seek                 archive is seekable
 31       --no-check-device      do not check device numbers when creating
 32                              incremental archives
 33       --no-seek              archive is not seekable
 34       --occurrence[=NUMBER]  process only the NUMBERth occurrence of each file
 35                              in the archive; this option is valid only in
 36                              conjunction with one of the subcommands --delete,
 37                              --diff, --extract or --list and when a list of
 38                              files is given either on the command line or via
 39                              the -T option; NUMBER defaults to 1
 40       --sparse-version=MAJOR[.MINOR]
 41                              set version of the sparse format to use (implies
 42                              --sparse)
 43   -S, --sparse               handle sparse files efficiently
 44 
 45  Overwrite control:
 46 
 47   -k, --keep-old-files       dont replace existing files when extracting,
 48                              treat them as errors
 49       --keep-directory-symlink   preserve existing symlinks to directories when
 50                              extracting
 51       --keep-newer-files     dont replace existing files that are newer than
 52                              their archive copies
 53       --no-overwrite-dir     preserve metadata of existing directories
 54       --overwrite            overwrite existing files when extracting
 55       --overwrite-dir        overwrite metadata of existing directories when
 56                              extracting (default)
 57       --recursive-unlink     empty hierarchies prior to extracting directory
 58       --remove-files         remove files after adding them to the archive
 59       --skip-old-files       dont replace existing files when extracting,
 60                              silently skip over them
 61   -U, --unlink-first         remove each file prior to extracting over it
 62   -W, --verify               attempt to verify the archive after writing it
 63 
 64  Select output stream:
 65 
 66       --ignore-command-error ignore exit codes of children
 67       --no-ignore-command-error   treat non-zero exit codes of children as
 68                              error
 69   -O, --to-stdout            extract files to standard output
 70       --to-command=COMMAND   pipe extracted files to another program
 71 
 72  Handling of file attributes:
 73 
 74       --atime-preserve[=METHOD]   preserve access times on dumped files, either
 75                              by restoring the times after reading
 76                              (METHOD=replace; default) or by not setting the
 77                              times in the first place (METHOD=system)
 78       --delay-directory-restore   delay setting modification times and
 79                              permissions of extracted directories until the end
 80                              of extraction
 81       --group=NAME           force NAME as group for added files
 82       --mode=CHANGES         force (symbolic) mode CHANGES for added files
 83       --mtime=DATE-OR-FILE   set mtime for added files from DATE-OR-FILE
 84   -m, --touch                dont extract file modified time
 85       --no-delay-directory-restore
 86                              cancel the effect of --delay-directory-restore
 87                              option
 88       --no-same-owner        extract files as yourself (default for ordinary
 89                              users)
 90       --no-same-permissions  apply the users umask when extracting permissions
 91                              from the archive (default for ordinary users)
 92       --numeric-owner        always use numbers for user/group names
 93       --owner=NAME           force NAME as owner for added files
 94   -p, --preserve-permissions, --same-permissions
 95                              extract information about file permissions
 96                              (default for superuser)
 97       --preserve             same as both -p and -s
 98       --same-owner           try extracting files with the same ownership as
 99                              exists in the archive (default for superuser)
100   -s, --preserve-order, --same-order
101                              member arguments are listed in the same order as
102                              the files in the archive
103 
104  Handling of extended file attributes:
105 
106       --acls                 Enable the POSIX ACLs support
107       --no-acls              Disable the POSIX ACLs support
108       --no-selinux           Disable the SELinux context support
109       --no-xattrs            Disable extended attributes support
110       --selinux              Enable the SELinux context support
111       --xattrs               Enable extended attributes support
112       --xattrs-exclude=MASK  specify the exclude pattern for xattr keys
113       --xattrs-include=MASK  specify the include pattern for xattr keys
114 
115  Device selection and switching:
116 
117   -f, --file=ARCHIVE         use archive file or device ARCHIVE
118       --force-local          archive file is local even if it has a colon
119   -F, --info-script=NAME, --new-volume-script=NAME
120                              run script at end of each tape (implies -M)
121   -L, --tape-length=NUMBER   change tape after writing NUMBER x 1024 bytes
122   -M, --multi-volume         create/list/extract multi-volume archive
123       --rmt-command=COMMAND  use given rmt COMMAND instead of rmt
124       --rsh-command=COMMAND  use remote COMMAND instead of rsh
125       --volno-file=FILE      use/update the volume number in FILE
126 
127  Device blocking:
128 
129   -b, --blocking-factor=BLOCKS   BLOCKS x 512 bytes per record
130   -B, --read-full-records    reblock as we read (for 4.2BSD pipes)
131   -i, --ignore-zeros         ignore zeroed blocks in archive (means EOF)
132       --record-size=NUMBER   NUMBER of bytes per record, multiple of 512
133 
134  Archive format selection:
135 
136   -H, --format=FORMAT        create archive of the given format
137 
138  FORMAT is one of the following:
139 
140     gnu                      GNU tar 1.13.x format
141     oldgnu                   GNU format as per tar <= 1.12
142     pax                      POSIX 1003.1-2001 (pax) format
143     posix                    same as pax
144     ustar                    POSIX 1003.1-1988 (ustar) format
145     v7                       old V7 tar format
146 
147       --old-archive, --portability
148                              same as --format=v7
149       --pax-option=keyword[[:]=value][,keyword[[:]=value]]...
150                              control pax keywords
151       --posix                same as --format=posix
152   -V, --label=TEXT           create archive with volume name TEXT; at
153                              list/extract time, use TEXT as a globbing pattern
154                              for volume name
155 
156  Compression options:
157 
158   -a, --auto-compress        use archive suffix to determine the compression
159                              program
160   -I, --use-compress-program=PROG
161                              filter through PROG (must accept -d)
162   -j, --bzip2                filter the archive through bzip2
163   -J, --xz                   filter the archive through xz
164       --lzip                 filter the archive through lzip
165       --lzma                 filter the archive through lzma
166       --lzop
167       --no-auto-compress     do not use archive suffix to determine the
168                              compression program
169   -z, --gzip, --gunzip, --ungzip   filter the archive through gzip
170   -Z, --compress, --uncompress   filter the archive through compress
171 
172  Local file selection:
173 
174       --add-file=FILE        add given FILE to the archive (useful if its name
175                              starts with a dash)
176       --backup[=CONTROL]     backup before removal, choose version CONTROL
177   -C, --directory=DIR        change to directory DIR
178       --exclude=PATTERN      exclude files, given as a PATTERN
179       --exclude-backups      exclude backup and lock files
180       --exclude-caches       exclude contents of directories containing
181                              CACHEDIR.TAG, except for the tag file itself
182       --exclude-caches-all   exclude directories containing CACHEDIR.TAG
183       --exclude-caches-under exclude everything under directories containing
184                              CACHEDIR.TAG
185       --exclude-tag=FILE     exclude contents of directories containing FILE,
186                              except for FILE itself
187       --exclude-tag-all=FILE exclude directories containing FILE
188       --exclude-tag-under=FILE   exclude everything under directories
189                              containing FILE
190       --exclude-vcs          exclude version control system directories
191   -h, --dereference          follow symlinks; archive and dump the files they
192                              point to
193       --hard-dereference     follow hard links; archive and dump the files they
194                              refer to
195   -K, --starting-file=MEMBER-NAME
196                              begin at member MEMBER-NAME when reading the
197                              archive
198       --newer-mtime=DATE     compare date and time when data changed only
199       --no-null              disable the effect of the previous --null option
200       --no-recursion         avoid descending automatically in directories
201       --no-unquote           do not unquote filenames read with -T
202       --null                 -T reads null-terminated names, disable -C
203   -N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE
204                              only store files newer than DATE-OR-FILE
205       --one-file-system      stay in local file system when creating archive
206   -P, --absolute-names       dont strip leading `/s from file names
207       --recursion            recurse into directories (default)
208       --suffix=STRING        backup before removal, override usual suffix (~
209                              unless overridden by environment variable
210                              SIMPLE_BACKUP_SUFFIX)
211   -T, --files-from=FILE      get names to extract or create from FILE
212       --unquote              unquote filenames read with -T (default)
213   -X, --exclude-from=FILE    exclude patterns listed in FILE
214 
215  File name transformations:
216 
217       --strip-components=NUMBER   strip NUMBER leading components from file
218                              names on extraction
219       --transform=EXPRESSION, --xform=EXPRESSION
220                              use sed replace EXPRESSION to transform file
221                              names
222 
223  File name matching options (affect both exclude and include patterns):
224 
225       --anchored             patterns match file name start
226       --ignore-case          ignore case
227       --no-anchored          patterns match after any `/ (default for
228                              exclusion)
229       --no-ignore-case       case sensitive matching (default)
230       --no-wildcards         verbatim string matching
231       --no-wildcards-match-slash   wildcards do not match `/232       --wildcards            use wildcards (default)
233       --wildcards-match-slash   wildcards match `/ (default for exclusion)
234 
235  Informative output:
236 
237       --checkpoint[=NUMBER]  display progress messages every NUMBERth record
238                              (default 10)
239       --checkpoint-action=ACTION   execute ACTION on each checkpoint
240       --full-time            print file time to its full resolution
241       --index-file=FILE      send verbose output to FILE
242   -l, --check-links          print a message if not all links are dumped
243       --no-quote-chars=STRING   disable quoting for characters from STRING
244       --quote-chars=STRING   additionally quote characters from STRING
245       --quoting-style=STYLE  set name quoting style; see below for valid STYLE
246                              values
247   -R, --block-number         show block number within archive with each message
248                             
249       --show-defaults        show tar defaults
250       --show-omitted-dirs    when listing or extracting, list each directory
251                              that does not match search criteria
252       --show-transformed-names, --show-stored-names
253                              show file or archive names after transformation
254       --totals[=SIGNAL]      print total bytes after processing the archive;
255                              with an argument - print total bytes when this
256                              SIGNAL is delivered; Allowed signals are: SIGHUP,
257                              SIGQUIT, SIGINT, SIGUSR1 and SIGUSR2; the names
258                              without SIG prefix are also accepted
259       --utc                  print file modification times in UTC
260   -v, --verbose              verbosely list files processed
261       --warning=KEYWORD      warning control
262   -w, --interactive, --confirmation
263                              ask for confirmation for every action
264 
265  Compatibility options:
266 
267   -o                         when creating, same as --old-archive; when
268                              extracting, same as --no-same-owner
269 
270  Other options:
271 
272   -?, --help                 give this help list
273       --restrict             disable use of some potentially harmful options
274       --usage                give a short usage message
275       --version              print program version
276 
277 Mandatory or optional arguments to long options are also mandatory or optional
278 for any corresponding short options.
279 
280 The backup suffix is `~, unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
281 The version control may be set with --backup or VERSION_CONTROL, values are:
282 
283   none, off       never make backups
284   t, numbered     make numbered backups
285   nil, existing   numbered if numbered backups exist, simple otherwise
286   never, simple   always make simple backups
287 
288 Valid arguments for the --quoting-style option are:
289 
290   literal
291   shell
292   shell-always
293   c
294   c-maybe
295   escape
296   locale
297   clocale
298 
299 *This* tar defaults to:
300 --format=gnu -f- -b20 --quoting-style=escape --rmt-command=/etc/rmt
301 --rsh-command=/usr/bin/ssh
302 
303 Report bugs to <bug-tar@gnu.org>.
View Code

man tar

技术图片
  1 TAR(1)                                                                                 User Commands                                                                                 TAR(1)
  2 
  3 
  4 
  5 NAME
  6        tar - manual page for tar 1.26
  7 
  8 SYNOPSIS
  9        tar [OPTION...] [FILE]...
 10 
 11 DESCRIPTION
 12        GNU `tar saves many files together into a single tape or disk archive, and can restore individual files from the archive.
 13 
 14        Note  that  this manual page contains just very brief description (or more like a list of possible functionality) originally generated by the help2man utility.  The full documenta‐
 15        tion 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
 16        manual.
 17 
 18 EXAMPLES
 19        tar -cf archive.tar foo bar
 20               # Create archive.tar from files foo and bar.
 21 
 22        tar -tvf archive.tar
 23               # List all files in archive.tar verbosely.
 24 
 25        tar -xf archive.tar
 26               # Extract all files from archive.tar.
 27 
 28 DEFAULTS
 29        *This* tar installation defaults to:
 30 
 31        --format=gnu -f- -b20 --quoting-style=escape --rmt-command=/sbin/rmt --rsh-command=/usr/bin/rsh
 32 
 33 Main operation mode:
 34        -A, --catenate, --concatenate
 35               append tar files to an archive
 36 
 37        -c, --create
 38               create a new archive
 39 
 40        -d, --diff, --compare
 41               find differences between archive and file system
 42 
 43        --delete
 44               delete from the archive (not on mag tapes!)
 45 
 46        -r, --append
 47               append files to the end of an archive
 48 
 49        -t, --list
 50               list the contents of an archive
 51 
 52        --test-label
 53               test the archive volume label and exit
 54 
 55        -u, --update
 56               only append files newer than copy in archive
 57 
 58        -x, --extract, --get
 59               extract files from an archive
 60 
 61 Common options:
 62        -C, --directory=DIR
 63               change to directory DIR
 64 
 65        -f, --file=ARCHIVE
 66               use archive file or device ARCHIVE
 67 
 68        -j, --bzip2
 69               filter the archive through bzip2
 70 
 71         -J, --xz
 72               filter the archive through xz
 73 
 74        -p, --preserve-permissions
 75               extract  information  about  file permissions (default for superuser)
 76 
 77        -v, --verbose
 78               verbosely list files processed
 79 
 80        -z, --gzip
 81               filter the archive through gzip
 82 
 83 
 84 Operation modifiers:
 85        --check-device
 86               check device numbers when creating incremental archives (default)
 87 
 88        -g, --listed-incremental=FILE
 89               handle new GNU-format incremental backup
 90 
 91        -G, --incremental
 92               handle old GNU-format incremental backup
 93 
 94        --ignore-failed-read
 95               do not exit with nonzero on unreadable files
 96 
 97        --level=NUMBER
 98               dump level for created listed-incremental archive
 99 
100        -n, --seek
101               archive is seekable
102 
103        --no-check-device
104               do not check device numbers when creating incremental archives
105 
106        --no-seek
107               archive is not seekable
108 
109        --occurrence[=NUMBER]
110               process  only the NUMBERth occurrence of each file in the archive; this option is valid only in conjunction with one of the subcommands --delete, --diff, --extract or --list
111               and when a list of files is given either on the command line or via the -T option; NUMBER defaults to 1
112 
113        --sparse-version=MAJOR[.MINOR]
114               set version of the sparse format to use (implies --sparse)
115 
116        -S, --sparse
117               handle sparse files efficiently
118 
119 Overwrite control:
120        -k, --keep-old-files
121               dont replace existing files when extracting, treat them as errors
122 
123        --keep-newer-files
124               dont replace existing files that are newer than their archive copies
125 
126        --keep-directory-symlink
127               Dont replace existing symlinks to directories when extracting.
128 
129        --no-overwrite-dir
130               preserve metadata of existing directories
131 
132        --overwrite
133               overwrite existing files when extracting
134 
135        --overwrite-dir
136               overwrite metadata of existing directories when extracting (default)
137 
138        --recursive-unlink
139               empty hierarchies prior to extracting directory
140 
141        --remove-files
142               remove files after adding them to the archive
143 
144        --skip-old-files
145               dont replace existing files when extracting, silently skip over them
146 
147        -U, --unlink-first
148               remove each file prior to extracting over it
149 
150        -W, --verify
151               attempt to verify the archive after writing it
152 
153 Select output stream:
154        --ignore-command-error ignore exit codes of children
155 
156        --no-ignore-command-error
157               treat non-zero exit codes of children as error
158 
159        -O, --to-stdout
160               extract files to standard output
161 
162        --to-command=COMMAND
163               pipe extracted files to another program
164 
165 Handling of file attributes:
166        --atime-preserve[=METHOD]
167               preserve access times on dumped files, either by restoring the times after reading (METHOD=replace; default) or by not setting the times in the first  place  (METHOD=sys‐
168               tem)
169 
170        --delay-directory-restore
171               delay setting modification times and permissions of extracted directories until the end of extraction
172 
173        --group=NAME
174               force NAME as group for added files
175 
176        --mode=CHANGES
177               force (symbolic) mode CHANGES for added files
178 
179        --mtime=DATE-OR-FILE
180               set mtime for added files from DATE-OR-FILE
181 
182        -m, --touch
183               dont extract file modified time
184 
185        --no-delay-directory-restore
186               cancel the effect of --delay-directory-restore option
187 
188        --no-same-owner
189               extract files as yourself (default for ordinary users)
190 
191        --no-same-permissions
192               apply the users umask when extracting permissions from the archive (default for ordinary users)
193 
194        --numeric-owner
195               always use numbers for user/group names
196 
197        --owner=NAME
198               force NAME as owner for added files
199 
200        -p, --preserve-permissions, --same-permissions
201               extract information about file permissions (default for superuser)
202 
203        --preserve
204               same as both -p and -s
205 
206        --same-owner
207               try extracting files with the same ownership as exists in the archive (default for superuser)
208 
209        -s, --preserve-order, --same-order
210               sort names to extract to match archive
211 
212 Handling of extended file attributes:
213        --acls Enable the POSIX ACLs support
214 
215        --no-acls
216               Disable the POSIX ACLs support
217 
218        --no-selinux
219               Disable the SELinux context support
220 
221        --no-xattrs
222               Disable extended attributes support
223 
224        --selinux
225               Enable the SELinux context support
226 
227        --xattrs
228               Enable extended attributes support
229 
230        --xattrs-exclude=MASK
231               specify the exclude pattern for xattr keys
232 
233        --xattrs-include=MASK
234               specify the include pattern for xattr keys
235 
236 Device selection and switching:
237        -f, --file=ARCHIVE
238               use archive file or device ARCHIVE
239 
240        --force-local
241               archive file is local even if it has a colon
242 
243        -F, --info-script=NAME, --new-volume-script=NAME
244               run script at end of each tape (implies -M)
245 
246        -L, --tape-length=NUMBER
247               change tape after writing NUMBER x 1024 bytes
248 
249        -M, --multi-volume
250               create/list/extract multi-volume archive
251 
252        --rmt-command=COMMAND
253               use given rmt COMMAND instead of rmt
254 
255        --rsh-command=COMMAND
256               use remote COMMAND instead of rsh
257 
258        --volno-file=FILE
259               use/update the volume number in FILE
260 
261 Device blocking:
262        -b, --blocking-factor=BLOCKS
263               BLOCKS x 512 bytes per record
264 
265        -B, --read-full-records
266               reblock as we read (for 4.2BSD pipes)
267 
268        -i, --ignore-zeros
269               ignore zeroed blocks in archive (means EOF)
270 
271        --record-size=NUMBER
272               NUMBER of bytes per record, multiple of 512
273 
274 Archive format selection:
275        -H, --format=FORMAT
276               create archive of the given format
277 
278               FORMAT is one of the following:
279 
280                      gnu    GNU tar 1.13.x format
281 
282                      oldgnu GNU format as per tar <= 1.12
283 
284                      pax    POSIX 1003.1-2001 (pax) format
285 
286                      posix  same as pax
287 
288                      ustar  POSIX 1003.1-1988 (ustar) format
289 
290                      v7     old V7 tar format
291 
292        --old-archive, --portability
293               same as --format=v7
294 
295        --pax-option=keyword[[:]=value][,keyword[[:]=value]]...
296               control pax keywords
297 
298        --posix
299               same as --format=posix
300 
301        -V, --label=TEXT
302               create archive with volume name TEXT; at list/extract time, use TEXT as a globbing pattern for volume name
303 
304 Compression options:
305        -a, --auto-compress
306               use archive suffix to determine the compression program
307 
308        -I, --use-compress-program=PROG
309               filter through PROG (must accept -d)
310 
311        -j, --bzip2
312               filter the archive through bzip2
313 
314        -J, --xz
315               filter the archive through xz
316 
317        --lzip filter the archive through lzip
318 
319        --lzma filter the archive through lzma
320 
321        --lzop
322 
323        --no-auto-compress
324               do not use archive suffix to determine the compression program
325 
326        -z, --gzip, --gunzip, --ungzip
327               filter the archive through gzip
328 
329        -Z, --compress, --uncompress
330               filter the archive through compress
331 
332        Note: You might need to install external program (lzip/ncompress/lzma...) to use some of these compression options
333 
334 Local file selection:
335        --add-file=FILE
336               add given FILE to the archive (useful if its name starts with a dash)
337 
338        --backup[=CONTROL]
339               backup before removal, choose version CONTROL
340 
341        -C, --directory=DIR
342               change to directory DIR
343 
344        --exclude=PATTERN
345               exclude files, given as a PATTERN
346 
347        --exclude-backups
348               exclude backup and lock files
349 
350        --exclude-caches
351               exclude contents of directories containing CACHEDIR.TAG, except for the tag file itself
352 
353        --exclude-caches-all
354               exclude directories containing CACHEDIR.TAG
355 
356        --exclude-caches-under exclude everything under directories containing
357               CACHEDIR.TAG
358 
359        --exclude-tag=FILE
360               exclude contents of directories containing FILE, except for FILE itself
361 
362        --exclude-tag-all=FILE exclude directories containing FILE
363 
364        --exclude-tag-under=FILE
365               exclude everything under directories containing FILE
366 
367        --exclude-vcs
368               exclude version control system directories
369 
370        -h, --dereference
371               follow symlinks; archive and dump the files they point to
372 
373        --hard-dereference
374               follow hard links; archive and dump the files they refer to
375 
376        -K, --starting-file=MEMBER-NAME
377               begin at member MEMBER-NAME in the archive
378 
379        --newer-mtime=DATE
380               compare date and time when data changed only
381 
382        --no-null
383               disable the effect of the previous --null option
384 
385        --no-recursion
386               avoid descending automatically in directories
387 
388        --no-unquote
389               do not unquote filenames read with -T
390 
391        --null                 -T reads null-terminated names, disable -C
392 
393        -N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE
394               only store files newer than DATE-OR-FILE
395 
396        --one-file-system
397               stay in local file system when creating archive
398 
399        -P, --absolute-names
400               dont strip leading `/s from file names
401 
402        --recursion
403               recurse into directories (default)
404 
405        --suffix=STRING
406               backup before removal, override usual suffix (~ unless overridden by environment variable SIMPLE_BACKUP_SUFFIX)
407 
408        -T, --files-from=FILE
409               get names to extract or create from FILE
410 
411        --unquote
412               unquote filenames read with -T (default)
413 
414        -X, --exclude-from=FILE
415               exclude patterns listed in FILE
416 
417 File name transformations:
418        --strip-components=NUMBER
419               strip NUMBER leading components from file names on extraction
420 
421        --transform=EXPRESSION, --xform=EXPRESSION
422               use sed replace EXPRESSION to transform file names
423 
424               File name matching options (affect both exclude and include patterns):
425 
426        --anchored
427               patterns match file name start
428 
429        --ignore-case
430               ignore case
431 
432        --no-anchored
433               patterns match after any `/ (default for exclusion)
434 
435        --no-ignore-case
436               case sensitive matching (default)
437 
438        --no-wildcards
439               verbatim string matching
440 
441        --no-wildcards-match-slash
442               wildcards do not match `/443 
444        --wildcards
445               use wildcards (default)
446 
447        --wildcards-match-slash
448               wildcards match `/ (default for exclusion)
449 
450 Informative output:
451        --checkpoint[=NUMBER]
452               display progress messages every NUMBERth record (default 10)
453 
454        --checkpoint-action=ACTION
455               execute ACTION on each checkpoint
456 
457        --full-time
458               print file time to its full resolution
459 
460        --index-file=FILE
461               send verbose output to FILE
462 
463        -l, --check-links
464               print a message if not all links are dumped
465 
466        --no-quote-chars=STRING
467               disable quoting for characters from STRING
468 
469        --quote-chars=STRING
470               additionally quote characters from STRING
471 
472        --quoting-style=STYLE
473               set name quoting style; see below for valid STYLE values
474 
475        -R, --block-number
476               show block number within archive with each message
477 
478        --show-defaults
479               show tar defaults
480 
481        --show-omitted-dirs
482               when listing or extracting, list each directory that does not match search criteria
483 
484        --show-transformed-names, --show-stored-names
485               show file or archive names after transformation
486 
487        --totals[=SIGNAL]
488               print total bytes after processing the archive; with an argument - print total bytes when this SIGNAL is delivered; Allowed signals are: SIGHUP, SIGQUIT, SIGINT, SIGUSR1 and
489               SIGUSR2; the names without SIG prefix are also accepted
490 
491        --utc  print file modification dates in UTC
492 
493        -v, --verbose
494               verbosely list files processed
495 
496        --warning=KEYWORD
497               warning control
498 
499        -w, --interactive, --confirmation
500               ask for confirmation for every action
501 
502 Compatibility options:
503        -o     when creating, same as --old-archive; when extracting, same as --no-same-owner
504 
505 Other options:
506        -?, --help
507               give this help list
508 
509        --restrict
510               disable use of some potentially harmful options
511 
512        --usage
513               give a short usage message
514 
515        --version
516               print program version
517 
518        Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options.
519 
520        The backup suffix is `~, unless set with --suffix or SIMPLE_BACKUP_SUFFIX.  The version control may be set with --backup or VERSION_CONTROL, values are:
521 
522        none, off
523               never make backups
524 
525        t, numbered
526               make numbered backups
527 
528        nil, existing
529               numbered if numbered backups exist, simple otherwise
530 
531        never, simple
532               always make simple backups
533 
534        Valid arguments for the --quoting-style option are:
535 
536               literal shell shell-always c c-maybe escape locale clocale
537 
538 AUTHOR
539        Written by John Gilmore and Jay Fenlason.
540 
541 REPORTING BUGS
542        Report bugs to <bug-tar@gnu.org>.
543 
544 COPYRIGHT
545        Copyright © 2013 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
546        This is free software: you are free to change and redistribute it.  There is NO WARRANTY, to the extent permitted by law.
547 
548 
549 
550 tar 1.26                                                                               February 2013                                                                                 TAR(1)
View Code

 

Linux命令:tar

标签:输出   更新   rri   iss   click   log   sim   method   null   

原文地址:https://www.cnblogs.com/ChinaGo/p/10563127.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!