]> git.cworth.org Git - tar/blob - doc/tar.info-1
Imported Upstream version 1.21
[tar] / doc / tar.info-1
1 This is tar.info, produced by makeinfo version 4.13 from tar.texi.
2
3 This manual is for GNU `tar' (version 1.21, 30 October 2008), which
4 creates and extracts files from archives.
5
6    Copyright (C) 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2003,
7 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
8
9      Permission is granted to copy, distribute and/or modify this
10      document under the terms of the GNU Free Documentation License,
11      Version 1.1 or any later version published by the Free Software
12      Foundation; with no Invariant Sections, with the Front-Cover Texts
13      being "A GNU Manual," and with the Back-Cover Texts as in (a)
14      below.  A copy of the license is included in the section entitled
15      "GNU Free Documentation License".
16
17      (a) The FSF's Back-Cover Text is: "You have the freedom to copy
18      and modify this GNU manual.  Buying copies from the FSF supports
19      it in developing GNU and promoting software freedom."
20
21 INFO-DIR-SECTION Archiving
22 START-INFO-DIR-ENTRY
23 * Tar: (tar).                   Making tape (or disk) archives.
24 END-INFO-DIR-ENTRY
25
26 INFO-DIR-SECTION Individual utilities
27 START-INFO-DIR-ENTRY
28 * tar: (tar)tar invocation.                     Invoking GNU `tar'.
29 END-INFO-DIR-ENTRY
30
31 \1f
32 File: tar.info,  Node: Top,  Next: Introduction,  Up: (dir)
33
34 GNU tar: an archiver tool
35 *************************
36
37 This manual is for GNU `tar' (version 1.21, 30 October 2008), which
38 creates and extracts files from archives.
39
40    Copyright (C) 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2003,
41 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
42
43      Permission is granted to copy, distribute and/or modify this
44      document under the terms of the GNU Free Documentation License,
45      Version 1.1 or any later version published by the Free Software
46      Foundation; with no Invariant Sections, with the Front-Cover Texts
47      being "A GNU Manual," and with the Back-Cover Texts as in (a)
48      below.  A copy of the license is included in the section entitled
49      "GNU Free Documentation License".
50
51      (a) The FSF's Back-Cover Text is: "You have the freedom to copy
52      and modify this GNU manual.  Buying copies from the FSF supports
53      it in developing GNU and promoting software freedom."
54
55    The first part of this master menu lists the major nodes in this Info
56 document.  The rest of the menu lists all the lower level nodes.
57
58 * Menu:
59
60 * Introduction::
61 * Tutorial::
62 * tar invocation::
63 * operations::
64 * Backups::
65 * Choosing::
66 * Date input formats::
67 * Formats::
68 * Media::
69
70 Appendices
71
72 * Changes::
73 * Configuring Help Summary::
74 * Fixing Snapshot Files::
75 * Tar Internals::
76 * Genfile::
77 * Free Software Needs Free Documentation::
78 * Copying This Manual::
79 * Index of Command Line Options::
80 * Index::
81
82  --- The Detailed Node Listing ---
83
84 Introduction
85
86 * Book Contents::               What this Book Contains
87 * Definitions::                 Some Definitions
88 * What tar Does::               What `tar' Does
89 * Naming tar Archives::         How `tar' Archives are Named
90 * Authors::                     GNU `tar' Authors
91 * Reports::                     Reporting bugs or suggestions
92
93 Tutorial Introduction to `tar'
94
95 * assumptions::
96 * stylistic conventions::
97 * basic tar options::           Basic `tar' Operations and Options
98 * frequent operations::
99 * Two Frequent Options::
100 * create::                      How to Create Archives
101 * list::                        How to List Archives
102 * extract::                     How to Extract Members from an Archive
103 * going further::
104
105 Two Frequently Used Options
106
107 * file tutorial::
108 * verbose tutorial::
109 * help tutorial::
110
111 How to Create Archives
112
113 * prepare for examples::
114 * Creating the archive::
115 * create verbose::
116 * short create::
117 * create dir::
118
119 How to List Archives
120
121 * list dir::
122
123 How to Extract Members from an Archive
124
125 * extracting archives::
126 * extracting files::
127 * extract dir::
128 * extracting untrusted archives::
129 * failing commands::
130
131 Invoking GNU `tar'
132
133 * Synopsis::
134 * using tar options::
135 * Styles::
136 * All Options::
137 * help::
138 * defaults::
139 * verbose::
140 * checkpoints::
141 * interactive::
142
143 The Three Option Styles
144
145 * Long Options::                Long Option Style
146 * Short Options::               Short Option Style
147 * Old Options::                 Old Option Style
148 * Mixing::                      Mixing Option Styles
149
150 All `tar' Options
151
152 * Operation Summary::
153 * Option Summary::
154 * Short Option Summary::
155
156 GNU `tar' Operations
157
158 * Basic tar::
159 * Advanced tar::
160 * create options::
161 * extract options::
162 * backup::
163 * Applications::
164 * looking ahead::
165
166 Advanced GNU `tar' Operations
167
168 * Operations::
169 * append::
170 * update::
171 * concatenate::
172 * delete::
173 * compare::
174
175 How to Add Files to Existing Archives: `--append'
176
177 * appending files::             Appending Files to an Archive
178 * multiple::
179
180 Updating an Archive
181
182 * how to update::
183
184 Options Used by `--create'
185
186 * override::                  Overriding File Metadata.
187 * Ignore Failed Read::
188
189 Options Used by `--extract'
190
191 * Reading::                     Options to Help Read Archives
192 * Writing::                     Changing How `tar' Writes Files
193 * Scarce::                      Coping with Scarce Resources
194
195 Options to Help Read Archives
196
197 * read full records::
198 * Ignore Zeros::
199
200 Changing How `tar' Writes Files
201
202 * Dealing with Old Files::
203 * Overwrite Old Files::
204 * Keep Old Files::
205 * Keep Newer Files::
206 * Unlink First::
207 * Recursive Unlink::
208 * Data Modification Times::
209 * Setting Access Permissions::
210 * Directory Modification Times and Permissions::
211 * Writing to Standard Output::
212 * Writing to an External Program::
213 * remove files::
214
215 Coping with Scarce Resources
216
217 * Starting File::
218 * Same Order::
219
220 Performing Backups and Restoring Files
221
222 * Full Dumps::                  Using `tar' to Perform Full Dumps
223 * Incremental Dumps::           Using `tar' to Perform Incremental Dumps
224 * Backup Levels::               Levels of Backups
225 * Backup Parameters::           Setting Parameters for Backups and Restoration
226 * Scripted Backups::            Using the Backup Scripts
227 * Scripted Restoration::        Using the Restore Script
228
229 Setting Parameters for Backups and Restoration
230
231 * General-Purpose Variables::
232 * Magnetic Tape Control::
233 * User Hooks::
234 * backup-specs example::        An Example Text of `Backup-specs'
235
236 Choosing Files and Names for `tar'
237
238 * file::                        Choosing the Archive's Name
239 * Selecting Archive Members::
240 * files::                       Reading Names from a File
241 * exclude::                     Excluding Some Files
242 * wildcards::                   Wildcards Patterns and Matching
243 * quoting styles::              Ways of Quoting Special Characters in Names
244 * transform::                   Modifying File and Member Names
245 * after::                       Operating Only on New Files
246 * recurse::                     Descending into Directories
247 * one::                         Crossing File System Boundaries
248
249 Reading Names from a File
250
251 * nul::
252
253 Excluding Some Files
254
255 * problems with exclude::
256
257 Wildcards Patterns and Matching
258
259 * controlling pattern-matching::
260
261 Crossing File System Boundaries
262
263 * directory::                   Changing Directory
264 * absolute::                    Absolute File Names
265
266 Date input formats
267
268 * General date syntax::            Common rules.
269 * Calendar date items::            19 Dec 1994.
270 * Time of day items::              9:20pm.
271 * Time zone items::                EST, PDT, GMT.
272 * Day of week items::              Monday and others.
273 * Relative items in date strings:: next tuesday, 2 years ago.
274 * Pure numbers in date strings::   19931219, 1440.
275 * Seconds since the Epoch::        @1078100502.
276 * Specifying time zone rules::     TZ="America/New_York", TZ="UTC0".
277 * Authors of get_date::            Bellovin, Eggert, Salz, Berets, et al.
278
279 Controlling the Archive Format
280
281 * Compression::                 Using Less Space through Compression
282 * Attributes::                  Handling File Attributes
283 * Portability::                 Making `tar' Archives More Portable
284 * cpio::                        Comparison of `tar' and `cpio'
285
286 Using Less Space through Compression
287
288 * gzip::                        Creating and Reading Compressed Archives
289 * sparse::                      Archiving Sparse Files
290
291 Making `tar' Archives More Portable
292
293 * Portable Names::              Portable Names
294 * dereference::                 Symbolic Links
295 * hard links::                  Hard Links
296 * old::                         Old V7 Archives
297 * ustar::                       Ustar Archives
298 * gnu::                         GNU and old GNU format archives.
299 * posix::                       POSIX archives
300 * Checksumming::                Checksumming Problems
301 * Large or Negative Values::    Large files, negative time stamps, etc.
302 * Other Tars::                  How to Extract GNU-Specific Data Using
303                                 Other `tar' Implementations
304
305 GNU `tar' and POSIX `tar'
306
307 * PAX keywords:: Controlling Extended Header Keywords.
308
309 How to Extract GNU-Specific Data Using Other `tar' Implementations
310
311 * Split Recovery::       Members Split Between Volumes
312 * Sparse Recovery::      Sparse Members
313
314 Tapes and Other Archive Media
315
316 * Device::                      Device selection and switching
317 * Remote Tape Server::
318 * Common Problems and Solutions::
319 * Blocking::                    Blocking
320 * Many::                        Many archives on one tape
321 * Using Multiple Tapes::        Using Multiple Tapes
322 * label::                       Including a Label in the Archive
323 * verify::
324 * Write Protection::
325
326 Blocking
327
328 * Format Variations::           Format Variations
329 * Blocking Factor::             The Blocking Factor of an Archive
330
331 Many Archives on One Tape
332
333 * Tape Positioning::            Tape Positions and Tape Marks
334 * mt::                          The `mt' Utility
335
336 Using Multiple Tapes
337
338 * Multi-Volume Archives::       Archives Longer than One Tape or Disk
339 * Tape Files::                  Tape Files
340 * Tarcat::                      Concatenate Volumes into a Single Archive
341
342
343 Tar Internals
344
345 * Standard::           Basic Tar Format
346 * Extensions::         GNU Extensions to the Archive Format
347 * Sparse Formats::     Storing Sparse Files
348 * Snapshot Files::
349 * Dumpdir::
350
351 Storing Sparse Files
352
353 * Old GNU Format::
354 * PAX 0::                PAX Format, Versions 0.0 and 0.1
355 * PAX 1::                PAX Format, Version 1.0
356
357 Genfile
358
359 * Generate Mode::     File Generation Mode.
360 * Status Mode::       File Status Mode.
361 * Exec Mode::         Synchronous Execution mode.
362
363 Copying This Manual
364
365 * GNU Free Documentation License::  License for copying this manual
366
367 \1f
368 File: tar.info,  Node: Introduction,  Next: Tutorial,  Prev: Top,  Up: Top
369
370 1 Introduction
371 **************
372
373 GNU `tar' creates and manipulates "archives" which are actually
374 collections of many other files; the program provides users with an
375 organized and systematic method for controlling a large amount of data.
376 The name "tar" originally came from the phrase "Tape ARchive", but
377 archives need not (and these days, typically do not) reside on tapes.
378
379 * Menu:
380
381 * Book Contents::               What this Book Contains
382 * Definitions::                 Some Definitions
383 * What tar Does::               What `tar' Does
384 * Naming tar Archives::         How `tar' Archives are Named
385 * Authors::                     GNU `tar' Authors
386 * Reports::                     Reporting bugs or suggestions
387
388 \1f
389 File: tar.info,  Node: Book Contents,  Next: Definitions,  Up: Introduction
390
391 1.1 What this Book Contains
392 ===========================
393
394 The first part of this chapter introduces you to various terms that will
395 recur throughout the book.  It also tells you who has worked on GNU
396 `tar' and its documentation, and where you should send bug reports or
397 comments.
398
399    The second chapter is a tutorial (*note Tutorial::) which provides a
400 gentle introduction for people who are new to using `tar'.  It is meant
401 to be self contained, not requiring any reading from subsequent
402 chapters to make sense.  It moves from topic to topic in a logical,
403 progressive order, building on information already explained.
404
405    Although the tutorial is paced and structured to allow beginners to
406 learn how to use `tar', it is not intended solely for beginners.  The
407 tutorial explains how to use the three most frequently used operations
408 (`create', `list', and `extract') as well as two frequently used
409 options (`file' and `verbose').  The other chapters do not refer to the
410 tutorial frequently; however, if a section discusses something which is
411 a complex variant of a basic concept, there may be a cross reference to
412 that basic concept.  (The entire book, including the tutorial, assumes
413 that the reader understands some basic concepts of using a Unix-type
414 operating system; *note Tutorial::.)
415
416    The third chapter presents the remaining five operations, and
417 information about using `tar' options and option syntax.
418
419    The other chapters are meant to be used as a reference.  Each chapter
420 presents everything that needs to be said about a specific topic.
421
422    One of the chapters (*note Date input formats::) exists in its
423 entirety in other GNU manuals, and is mostly self-contained.  In
424 addition, one section of this manual (*note Standard::) contains a big
425 quote which is taken directly from `tar' sources.
426
427    In general, we give both long and short (abbreviated) option names
428 at least once in each section where the relevant option is covered, so
429 that novice readers will become familiar with both styles.  (A few
430 options have no short versions, and the relevant sections will indicate
431 this.)
432
433 \1f
434 File: tar.info,  Node: Definitions,  Next: What tar Does,  Prev: Book Contents,  Up: Introduction
435
436 1.2 Some Definitions
437 ====================
438
439 The `tar' program is used to create and manipulate `tar' archives.  An
440 "archive" is a single file which contains the contents of many files,
441 while still identifying the names of the files, their owner(s), and so
442 forth.  (In addition, archives record access permissions, user and
443 group, size in bytes, and data modification time.  Some archives also
444 record the file names in each archived directory, as well as other file
445 and directory information.)  You can use `tar' to "create" a new
446 archive in a specified directory.
447
448    The files inside an archive are called "members".  Within this
449 manual, we use the term "file" to refer only to files accessible in the
450 normal ways (by `ls', `cat', and so forth), and the term "member" to
451 refer only to the members of an archive.  Similarly, a "file name" is
452 the name of a file, as it resides in the file system, and a "member
453 name" is the name of an archive member within the archive.
454
455    The term "extraction" refers to the process of copying an archive
456 member (or multiple members) into a file in the file system.  Extracting
457 all the members of an archive is often called "extracting the archive".
458 The term "unpack" can also be used to refer to the extraction of many
459 or all the members of an archive.  Extracting an archive does not
460 destroy the archive's structure, just as creating an archive does not
461 destroy the copies of the files that exist outside of the archive.  You
462 may also "list" the members in a given archive (this is often thought
463 of as "printing" them to the standard output, or the command line), or
464 "append" members to a pre-existing archive.  All of these operations
465 can be performed using `tar'.
466
467 \1f
468 File: tar.info,  Node: What tar Does,  Next: Naming tar Archives,  Prev: Definitions,  Up: Introduction
469
470 1.3 What `tar' Does
471 ===================
472
473 The `tar' program provides the ability to create `tar' archives, as
474 well as various other kinds of manipulation.  For example, you can use
475 `tar' on previously created archives to extract files, to store
476 additional files, or to update or list files which were already stored.
477
478    Initially, `tar' archives were used to store files conveniently on
479 magnetic tape.  The name `tar' comes from this use; it stands for
480 `t'ape `ar'chiver.  Despite the utility's name, `tar' can direct its
481 output to available devices, files, or other programs (using pipes).
482 `tar' may even access remote devices or files (as archives).
483
484    You can use `tar' archives in many ways.  We want to stress a few of
485 them: storage, backup, and transportation.
486
487 Storage
488      Often, `tar' archives are used to store related files for
489      convenient file transfer over a network.  For example, the GNU
490      Project distributes its software bundled into `tar' archives, so
491      that all the files relating to a particular program (or set of
492      related programs) can be transferred as a single unit.
493
494      A magnetic tape can store several files in sequence.  However, the
495      tape has no names for these files; it only knows their relative
496      position on the tape.  One way to store several files on one tape
497      and retain their names is by creating a `tar' archive.  Even when
498      the basic transfer mechanism can keep track of names, as FTP can,
499      the nuisance of handling multiple files, directories, and multiple
500      links makes `tar' archives useful.
501
502      Archive files are also used for long-term storage.  You can think
503      of this as transportation from the present into the future.  (It
504      is a science-fiction idiom that you can move through time as well
505      as in space; the idea here is that `tar' can be used to move
506      archives in all dimensions, even time!)
507
508 Backup
509      Because the archive created by `tar' is capable of preserving file
510      information and directory structure, `tar' is commonly used for
511      performing full and incremental backups of disks.  A backup puts a
512      collection of files (possibly pertaining to many users and
513      projects) together on a disk or a tape.  This guards against
514      accidental destruction of the information in those files.  GNU
515      `tar' has special features that allow it to be used to make
516      incremental and full dumps of all the files in a file system.
517
518 Transportation
519      You can create an archive on one system, transfer it to another
520      system, and extract the contents there.  This allows you to
521      transport a group of files from one system to another.
522
523 \1f
524 File: tar.info,  Node: Naming tar Archives,  Next: Authors,  Prev: What tar Does,  Up: Introduction
525
526 1.4 How `tar' Archives are Named
527 ================================
528
529 Conventionally, `tar' archives are given names ending with `.tar'.
530 This is not necessary for `tar' to operate properly, but this manual
531 follows that convention in order to accustom readers to it and to make
532 examples more clear.
533
534    Often, people refer to `tar' archives as "`tar' files," and archive
535 members as "files" or "entries".  For people familiar with the
536 operation of `tar', this causes no difficulty.  However, in this
537 manual, we consistently refer to "archives" and "archive members" to
538 make learning to use `tar' easier for novice users.
539
540 \1f
541 File: tar.info,  Node: Authors,  Next: Reports,  Prev: Naming tar Archives,  Up: Introduction
542
543 1.5 GNU `tar' Authors
544 =====================
545
546 GNU `tar' was originally written by John Gilmore, and modified by many
547 people.  The GNU enhancements were written by Jay Fenlason, then Joy
548 Kendall, and the whole package has been further maintained by Thomas
549 Bushnell, n/BSG, Franc,ois Pinard, Paul Eggert, and finally Sergey
550 Poznyakoff with the help of numerous and kind users.
551
552    We wish to stress that `tar' is a collective work, and owes much to
553 all those people who reported problems, offered solutions and other
554 insights, or shared their thoughts and suggestions.  An impressive, yet
555 partial list of those contributors can be found in the `THANKS' file
556 from the GNU `tar' distribution.
557
558    Jay Fenlason put together a draft of a GNU `tar' manual, borrowing
559 notes from the original man page from John Gilmore.  This was withdrawn
560 in version 1.11.  Thomas Bushnell, n/BSG and Amy Gorin worked on a
561 tutorial and manual for GNU `tar'.  Franc,ois Pinard put version 1.11.8
562 of the manual together by taking information from all these sources and
563 merging them.  Melissa Weisshaus finally edited and redesigned the book
564 to create version 1.12.  The book for versions from 1.14 up to 1.21
565 were edited by the current maintainer, Sergey Poznyakoff.
566
567    For version 1.12, Daniel Hagerty contributed a great deal of
568 technical consulting.  In particular, he is the primary author of *note
569 Backups::.
570
571    In July, 2003 GNU `tar' was put on CVS at savannah.gnu.org (see
572 `http://savannah.gnu.org/projects/tar'), and active development and
573 maintenance work has started again.  Currently GNU `tar' is being
574 maintained by Paul Eggert, Sergey Poznyakoff and Jeff Bailey.
575
576    Support for POSIX archives was added by Sergey Poznyakoff.
577
578 \1f
579 File: tar.info,  Node: Reports,  Prev: Authors,  Up: Introduction
580
581 1.6 Reporting bugs or suggestions
582 =================================
583
584 If you find problems or have suggestions about this program or manual,
585 please report them to `bug-tar@gnu.org'.
586
587    When reporting a bug, please be sure to include as much detail as
588 possible, in order to reproduce it.  .
589
590 \1f
591 File: tar.info,  Node: Tutorial,  Next: tar invocation,  Prev: Introduction,  Up: Top
592
593 2 Tutorial Introduction to `tar'
594 ********************************
595
596 This chapter guides you through some basic examples of three `tar'
597 operations: `--create', `--list', and `--extract'.  If you already know
598 how to use some other version of `tar', then you may not need to read
599 this chapter.  This chapter omits most complicated details about how
600 `tar' works.
601
602 * Menu:
603
604 * assumptions::
605 * stylistic conventions::
606 * basic tar options::           Basic `tar' Operations and Options
607 * frequent operations::
608 * Two Frequent Options::
609 * create::                      How to Create Archives
610 * list::                        How to List Archives
611 * extract::                     How to Extract Members from an Archive
612 * going further::
613
614 \1f
615 File: tar.info,  Node: assumptions,  Next: stylistic conventions,  Up: Tutorial
616
617 2.1 Assumptions this Tutorial Makes
618 ===================================
619
620 This chapter is paced to allow beginners to learn about `tar' slowly.
621 At the same time, we will try to cover all the basic aspects of these
622 three operations.  In order to accomplish both of these tasks, we have
623 made certain assumptions about your knowledge before reading this
624 manual, and the hardware you will be using:
625
626    * Before you start to work through this tutorial, you should
627      understand what the terms "archive" and "archive member" mean
628      (*note Definitions::).  In addition, you should understand
629      something about how Unix-type operating systems work, and you
630      should know how to use some basic utilities.  For example, you
631      should know how to create, list, copy, rename, edit, and delete
632      files and directories; how to change between directories; and how
633      to figure out where you are in the file system.  You should have
634      some basic understanding of directory structure and how files are
635      named according to which directory they are in.  You should
636      understand concepts such as standard output and standard input,
637      what various definitions of the term `argument' mean, and the
638      differences between relative and absolute file names.
639
640    * This manual assumes that you are working from your own home
641      directory (unless we state otherwise).  In this tutorial, you will
642      create a directory to practice `tar' commands in.  When we show
643      file names, we will assume that those names are relative to your
644      home directory.  For example, my home directory is
645      `/home/fsf/melissa'.  All of my examples are in a subdirectory of
646      the directory named by that file name; the subdirectory is called
647      `practice'.
648
649    * In general, we show examples of archives which exist on (or can be
650      written to, or worked with from) a directory on a hard disk.  In
651      most cases, you could write those archives to, or work with them
652      on any other device, such as a tape drive.  However, some of the
653      later examples in the tutorial and next chapter will not work on
654      tape drives.  Additionally, working with tapes is much more
655      complicated than working with hard disks.  For these reasons, the
656      tutorial does not cover working with tape drives.  *Note Media::,
657      for complete information on using `tar' archives with tape drives.
658
659
660 \1f
661 File: tar.info,  Node: stylistic conventions,  Next: basic tar options,  Prev: assumptions,  Up: Tutorial
662
663 2.2 Stylistic Conventions
664 =========================
665
666 In the examples, `$' represents a typical shell prompt.  It precedes
667 lines you should type; to make this more clear, those lines are shown
668 in `this font', as opposed to lines which represent the computer's
669 response; those lines are shown in `this font', or sometimes `like
670 this'.
671
672 \1f
673 File: tar.info,  Node: basic tar options,  Next: frequent operations,  Prev: stylistic conventions,  Up: Tutorial
674
675 2.3 Basic `tar' Operations and Options
676 ======================================
677
678 `tar' can take a wide variety of arguments which specify and define the
679 actions it will have on the particular set of files or the archive.
680 The main types of arguments to `tar' fall into one of two classes:
681 operations, and options.
682
683    Some arguments fall into a class called "operations"; exactly one of
684 these is both allowed and required for any instance of using `tar'; you
685 may _not_ specify more than one.  People sometimes speak of "operating
686 modes".  You are in a particular operating mode when you have specified
687 the operation which specifies it; there are eight operations in total,
688 and thus there are eight operating modes.
689
690    The other arguments fall into the class known as "options".  You are
691 not required to specify any options, and you are allowed to specify more
692 than one at a time (depending on the way you are using `tar' at that
693 time).  Some options are used so frequently, and are so useful for
694 helping you type commands more carefully that they are effectively
695 "required".  We will discuss them in this chapter.
696
697    You can write most of the `tar' operations and options in any of
698 three forms: long (mnemonic) form, short form, and old style.  Some of
699 the operations and options have no short or "old" forms; however, the
700 operations and options which we will cover in this tutorial have
701 corresponding abbreviations.  We will indicate those abbreviations
702 appropriately to get you used to seeing them.  (Note that the "old
703 style" option forms exist in GNU `tar' for compatibility with Unix
704 `tar'.  In this book we present a full discussion of this way of
705 writing options and operations (*note Old Options::), and we discuss
706 the other two styles of writing options (*Note Long Options::, and
707 *note Short Options::).
708
709    In the examples and in the text of this tutorial, we usually use the
710 long forms of operations and options; but the "short" forms produce the
711 same result and can make typing long `tar' commands easier.  For
712 example, instead of typing
713
714      tar --create --verbose --file=afiles.tar apple angst aspic
715
716 you can type
717      tar -c -v -f afiles.tar apple angst aspic
718
719 or even
720      tar -cvf afiles.tar apple angst aspic
721
722 For more information on option syntax, see *note Advanced tar::.  In
723 discussions in the text, when we name an option by its long form, we
724 also give the corresponding short option in parentheses.
725
726    The term, "option", can be confusing at times, since "operations"
727 are often lumped in with the actual, _optional_ "options" in certain
728 general class statements.  For example, we just talked about "short and
729 long forms of options and operations".  However, experienced `tar'
730 users often refer to these by shorthand terms such as, "short and long
731 options".  This term assumes that the "operations" are included, also.
732 Context will help you determine which definition of "options" to use.
733
734    Similarly, the term "command" can be confusing, as it is often used
735 in two different ways.  People sometimes refer to `tar' "commands".  A
736 `tar' "command" is the entire command line of user input which tells
737 `tar' what to do -- including the operation, options, and any arguments
738 (file names, pipes, other commands, etc.).  However, you will also
739 sometimes hear the term "the `tar' command".  When the word "command"
740 is used specifically like this, a person is usually referring to the
741 `tar' _operation_, not the whole line.  Again, use context to figure
742 out which of the meanings the speaker intends.
743
744 \1f
745 File: tar.info,  Node: frequent operations,  Next: Two Frequent Options,  Prev: basic tar options,  Up: Tutorial
746
747 2.4 The Three Most Frequently Used Operations
748 =============================================
749
750 Here are the three most frequently used operations (both short and long
751 forms), as well as a brief description of their meanings.  The rest of
752 this chapter will cover how to use these operations in detail.  We will
753 present the rest of the operations in the next chapter.
754
755 `--create'
756 `-c'
757      Create a new `tar' archive.
758
759 `--list'
760 `-t'
761      List the contents of an archive.
762
763 `--extract'
764 `-x'
765      Extract one or more members from an archive.
766
767 \1f
768 File: tar.info,  Node: Two Frequent Options,  Next: create,  Prev: frequent operations,  Up: Tutorial
769
770 2.5 Two Frequently Used Options
771 ===============================
772
773 To understand how to run `tar' in the three operating modes listed
774 previously, you also need to understand how to use two of the options to
775 `tar': `--file' (which takes an archive file as an argument) and
776 `--verbose'.  (You are usually not _required_ to specify either of
777 these options when you run `tar', but they can be very useful in making
778 things more clear and helping you avoid errors.)
779
780 * Menu:
781
782 * file tutorial::
783 * verbose tutorial::
784 * help tutorial::
785
786 \1f
787 File: tar.info,  Node: file tutorial,  Next: verbose tutorial,  Up: Two Frequent Options
788
789 The `--file' Option
790 -------------------
791
792 `--file=ARCHIVE-NAME'
793 `-f ARCHIVE-NAME'
794      Specify the name of an archive file.
795
796    You can specify an argument for the `--file=ARCHIVE-NAME' (`-f
797 ARCHIVE-NAME') option whenever you use `tar'; this option determines
798 the name of the archive file that `tar' will work on.
799
800    If you don't specify this argument, then `tar' will examine the
801 environment variable `TAPE'.  If it is set, its value will be used as
802 the archive name.  Otherwise, `tar' will use the default archive,
803 determined at the compile time. Usually it is standard output or some
804 physical tape drive attached to your machine (you can verify what the
805 default is by running `tar --show-defaults', *note defaults::).  If
806 there is no tape drive attached, or the default is not meaningful, then
807 `tar' will print an error message.  The error message might look
808 roughly like one of the following:
809
810      tar: can't open /dev/rmt8 : No such device or address
811      tar: can't open /dev/rsmt0 : I/O error
812
813 To avoid confusion, we recommend that you always specify an archive file
814 name by using `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME') when writing
815 your `tar' commands.  For more information on using the
816 `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME') option, see *note file::.
817
818 \1f
819 File: tar.info,  Node: verbose tutorial,  Next: help tutorial,  Prev: file tutorial,  Up: Two Frequent Options
820
821 The `--verbose' Option
822 ----------------------
823
824 `--verbose'
825 `-v'
826      Show the files being worked on as `tar' is running.
827
828    `--verbose' (`-v') shows details about the results of running `tar'.
829 This can be especially useful when the results might not be obvious.
830 For example, if you want to see the progress of `tar' as it writes
831 files into the archive, you can use the `--verbose' option.  In the
832 beginning, you may find it useful to use `--verbose' at all times; when
833 you are more accustomed to `tar', you will likely want to use it at
834 certain times but not at others.  We will use `--verbose' at times to
835 help make something clear, and we will give many examples both using
836 and not using `--verbose' to show the differences.
837
838    Each instance of `--verbose' on the command line increases the
839 verbosity level by one, so if you need more details on the output,
840 specify it twice.
841
842    When reading archives (`--list', `--extract', `--diff'), `tar' by
843 default prints only the names of the members being extracted.  Using
844 `--verbose' will show a full, `ls' style member listing.
845
846    In contrast, when writing archives (`--create', `--append',
847 `--update'), `tar' does not print file names by default.  So, a single
848 `--verbose' option shows the file names being added to the archive,
849 while two `--verbose' options enable the full listing.
850
851    For example, to create an archive in verbose mode:
852
853      $ tar -cvf afiles.tar apple angst aspic
854      apple
855      angst
856      aspic
857
858 Creating the same archive with the verbosity level 2 could give:
859
860      $ tar -cvvf afiles.tar apple angst aspic
861      -rw-r--r-- gray/staff    62373 2006-06-09 12:06 apple
862      -rw-r--r-- gray/staff    11481 2006-06-09 12:06 angst
863      -rw-r--r-- gray/staff    23152 2006-06-09 12:06 aspic
864
865 This works equally well using short or long forms of options.  Using
866 long forms, you would simply write out the mnemonic form of the option
867 twice, like this:
868
869      $ tar --create --verbose --verbose ...
870
871 Note that you must double the hyphens properly each time.
872
873    Later in the tutorial, we will give examples using
874 `--verbose --verbose'.
875
876    The full output consists of six fields:
877
878    * File type and permissions in symbolic form.  These are displayed
879      in the same format as the first column of `ls -l' output (*note
880      format=verbose: (fileutils)What information is listed.).
881
882    * Owner name and group separated by a slash character.  If these
883      data are not available (for example, when listing a `v7' format
884      archive), numeric ID values are printed instead.
885
886    * Size of the file, in bytes.
887
888    * File modification date in ISO 8601 format.
889
890    * File modification time.
891
892    * File name.  If the name contains any special characters (white
893      space, newlines, etc.) these are displayed in an unambiguous form
894      using so called "quoting style".  For the detailed discussion of
895      available styles and on how to use them, see *note quoting
896      styles::.
897
898      Depending on the file type, the name can be followed by some
899      additional information, described in the following table:
900
901     `-> LINK-NAME'
902           The file or archive member is a "symbolic link" and LINK-NAME
903           is the name of file it links to.
904
905     `link to LINK-NAME'
906           The file or archive member is a "hard link" and LINK-NAME is
907           the name of file it links to.
908
909     `--Long Link--'
910           The archive member is an old GNU format long link.  You will
911           normally not encounter this.
912
913     `--Long Name--'
914           The archive member is an old GNU format long name.  You will
915           normally not encounter this.
916
917     `--Volume Header--'
918           The archive member is a GNU "volume header" (*note Tape
919           Files::).
920
921     `--Continued at byte N--'
922           Encountered only at the beginning of a multi-volume archive
923           (*note Using Multiple Tapes::).  This archive member is a
924           continuation from the previous volume. The number N gives the
925           offset where the original file was split.
926
927     `unknown file type C'
928           An archive member of unknown type. C is the type character
929           from the archive header.  If you encounter such a message, it
930           means that either your archive contains proprietary member
931           types GNU `tar' is not able to handle, or the archive is
932           corrupted.
933
934
935    For example, here is an archive listing containing most of the
936 special suffixes explained above:
937
938      V--------- 0/0          1536 2006-06-09 13:07 MyVolume--Volume Header--
939      -rw-r--r-- gray/staff 456783 2006-06-09 12:06 aspic--Continued at
940      byte 32456--
941      -rw-r--r-- gray/staff  62373 2006-06-09 12:06 apple
942      lrwxrwxrwx gray/staff      0 2006-06-09 13:01 angst -> apple
943      -rw-r--r-- gray/staff  35793 2006-06-09 12:06 blues
944      hrw-r--r-- gray/staff      0 2006-06-09 12:06 music link to blues
945
946
947 \1f
948 File: tar.info,  Node: help tutorial,  Prev: verbose tutorial,  Up: Two Frequent Options
949
950 Getting Help: Using the `--help' Option
951 ---------------------------------------
952
953 `--help'
954      The `--help' option to `tar' prints out a very brief list of all
955      operations and option available for the current version of `tar'
956      available on your system.
957
958 \1f
959 File: tar.info,  Node: create,  Next: list,  Prev: Two Frequent Options,  Up: Tutorial
960
961 2.6 How to Create Archives
962 ==========================
963
964      _(This message will disappear, once this node revised.)_
965
966 One of the basic operations of `tar' is `--create' (`-c'), which you
967 use to create a `tar' archive.  We will explain `--create' first
968 because, in order to learn about the other operations, you will find it
969 useful to have an archive available to practice on.
970
971    To make this easier, in this section you will first create a
972 directory containing three files.  Then, we will show you how to create
973 an _archive_ (inside the new directory).  Both the directory, and the
974 archive are specifically for you to practice on.  The rest of this
975 chapter and the next chapter will show many examples using this
976 directory and the files you will create: some of those files may be
977 other directories and other archives.
978
979    The three files you will archive in this example are called `blues',
980 `folk', and `jazz'.  The archive is called `collection.tar'.
981
982    This section will proceed slowly, detailing how to use `--create' in
983 `verbose' mode, and showing examples using both short and long forms.
984 In the rest of the tutorial, and in the examples in the next chapter,
985 we will proceed at a slightly quicker pace.  This section moves more
986 slowly to allow beginning users to understand how `tar' works.
987
988 * Menu:
989
990 * prepare for examples::
991 * Creating the archive::
992 * create verbose::
993 * short create::
994 * create dir::
995
996 \1f
997 File: tar.info,  Node: prepare for examples,  Next: Creating the archive,  Up: create
998
999 2.6.1 Preparing a Practice Directory for Examples
1000 -------------------------------------------------
1001
1002 To follow along with this and future examples, create a new directory
1003 called `practice' containing files called `blues', `folk' and `jazz'.
1004 The files can contain any information you like: ideally, they should
1005 contain information which relates to their names, and be of different
1006 lengths.  Our examples assume that `practice' is a subdirectory of your
1007 home directory.
1008
1009    Now `cd' to the directory named `practice'; `practice' is now your
1010 "working directory".  (_Please note_: Although the full file name of
1011 this directory is `/HOMEDIR/practice', in our examples we will refer to
1012 this directory as `practice'; the HOMEDIR is presumed.
1013
1014    In general, you should check that the files to be archived exist
1015 where you think they do (in the working directory) by running `ls'.
1016 Because you just created the directory and the files and have changed to
1017 that directory, you probably don't need to do that this time.
1018
1019    It is very important to make sure there isn't already a file in the
1020 working directory with the archive name you intend to use (in this case,
1021 `collection.tar'), or that you don't care about its contents.  Whenever
1022 you use `create', `tar' will erase the current contents of the file
1023 named by `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME') if it exists.  `tar'
1024 will not tell you if you are about to overwrite an archive unless you
1025 specify an option which does this (*note backup::, for the information
1026 on how to do so).  To add files to an existing archive, you need to use
1027 a different option, such as `--append' (`-r'); see *note append:: for
1028 information on how to do this.
1029
1030 \1f
1031 File: tar.info,  Node: Creating the archive,  Next: create verbose,  Prev: prepare for examples,  Up: create
1032
1033 2.6.2 Creating the Archive
1034 --------------------------
1035
1036 To place the files `blues', `folk', and `jazz' into an archive named
1037 `collection.tar', use the following command:
1038
1039      $ tar --create --file=collection.tar blues folk jazz
1040
1041    The order of the arguments is not very important, _when using long
1042 option forms_.  You could also say:
1043
1044      $ tar blues --create folk --file=collection.tar jazz
1045
1046 However, you can see that this order is harder to understand; this is
1047 why we will list the arguments in the order that makes the commands
1048 easiest to understand (and we encourage you to do the same when you use
1049 `tar', to avoid errors).
1050
1051    Note that the sequence `--file=collection.tar' is considered to be
1052 _one_ argument.  If you substituted any other string of characters for
1053 `collection.tar',  then that string would become the name of the
1054 archive file you create.
1055
1056    The order of the options becomes more important when you begin to use
1057 short forms.  With short forms, if you type commands in the wrong order
1058 (even if you type them correctly in all other ways), you may end up with
1059 results you don't expect.  For this reason, it is a good idea to get
1060 into the habit of typing options in the order that makes inherent sense.
1061 *Note short create::, for more information on this.
1062
1063    In this example, you type the command as shown above: `--create' is
1064 the operation which creates the new archive (`collection.tar'), and
1065 `--file' is the option which lets you give it the name you chose.  The
1066 files, `blues', `folk', and `jazz', are now members of the archive,
1067 `collection.tar' (they are "file name arguments" to the `--create'
1068 operation.  *Note Choosing::, for the detailed discussion on these.)
1069 Now that they are in the archive, they are called _archive members_,
1070 not files.  (*note members: Definitions.).
1071
1072    When you create an archive, you _must_ specify which files you want
1073 placed in the archive.  If you do not specify any archive members, GNU
1074 `tar' will complain.
1075
1076    If you now list the contents of the working directory (`ls'), you
1077 will find the archive file listed as well as the files you saw
1078 previously:
1079
1080      blues   folk   jazz   collection.tar
1081
1082 Creating the archive `collection.tar' did not destroy the copies of the
1083 files in the directory.
1084
1085    Keep in mind that if you don't indicate an operation, `tar' will not
1086 run and will prompt you for one.  If you don't name any files, `tar'
1087 will complain.  You must have write access to the working directory, or
1088 else you will not be able to create an archive in that directory.
1089
1090    _Caution_: Do not attempt to use `--create' (`-c') to add files to
1091 an existing archive; it will delete the archive and write a new one.
1092 Use `--append' (`-r') instead.  *Note append::.
1093
1094 \1f
1095 File: tar.info,  Node: create verbose,  Next: short create,  Prev: Creating the archive,  Up: create
1096
1097 2.6.3 Running `--create' with `--verbose'
1098 -----------------------------------------
1099
1100 If you include the `--verbose' (`-v') option on the command line, `tar'
1101 will list the files it is acting on as it is working.  In verbose mode,
1102 the `create' example above would appear as:
1103
1104      $ tar --create --verbose --file=collection.tar blues folk jazz
1105      blues
1106      folk
1107      jazz
1108
1109    This example is just like the example we showed which did not use
1110 `--verbose', except that `tar' generated the remaining lines .
1111
1112    In the rest of the examples in this chapter, we will frequently use
1113 `verbose' mode so we can show actions or `tar' responses that you would
1114 otherwise not see, and which are important for you to understand.
1115
1116 \1f
1117 File: tar.info,  Node: short create,  Next: create dir,  Prev: create verbose,  Up: create
1118
1119 2.6.4 Short Forms with `create'
1120 -------------------------------
1121
1122 As we said before, the `--create' (`-c') operation is one of the most
1123 basic uses of `tar', and you will use it countless times.  Eventually,
1124 you will probably want to use abbreviated (or "short") forms of
1125 options.  A full discussion of the three different forms that options
1126 can take appears in *note Styles::; for now, here is what the previous
1127 example (including the `--verbose' (`-v') option) looks like using
1128 short option forms:
1129
1130      $ tar -cvf collection.tar blues folk jazz
1131      blues
1132      folk
1133      jazz
1134
1135 As you can see, the system responds the same no matter whether you use
1136 long or short option forms.
1137
1138    One difference between using short and long option forms is that,
1139 although the exact placement of arguments following options is no more
1140 specific when using short forms, it is easier to become confused and
1141 make a mistake when using short forms.  For example, suppose you
1142 attempted the above example in the following way:
1143
1144      $ tar -cfv collection.tar blues folk jazz
1145
1146 In this case, `tar' will make an archive file called `v', containing
1147 the files `blues', `folk', and `jazz', because the `v' is the closest
1148 "file name" to the `-f' option, and is thus taken to be the chosen
1149 archive file name.  `tar' will try to add a file called
1150 `collection.tar' to the `v' archive file; if the file `collection.tar'
1151 did not already exist, `tar' will report an error indicating that this
1152 file does not exist.  If the file `collection.tar' does already exist
1153 (e.g., from a previous command you may have run), then `tar' will add
1154 this file to the archive.  Because the `-v' option did not get
1155 registered, `tar' will not run under `verbose' mode, and will not
1156 report its progress.
1157
1158    The end result is that you may be quite confused about what happened,
1159 and possibly overwrite a file.  To illustrate this further, we will show
1160 you how an example we showed previously would look using short forms.
1161
1162    This example,
1163
1164      $ tar blues --create folk --file=collection.tar jazz
1165
1166 is confusing as it is.  When shown using short forms, however, it
1167 becomes much more so:
1168
1169      $ tar blues -c folk -f collection.tar jazz
1170
1171 It would be very easy to put the wrong string of characters immediately
1172 following the `-f', but doing that could sacrifice valuable data.
1173
1174    For this reason, we recommend that you pay very careful attention to
1175 the order of options and placement of file and archive names,
1176 especially when using short option forms.  Not having the option name
1177 written out mnemonically can affect how well you remember which option
1178 does what, and therefore where different names have to be placed.
1179
1180 \1f
1181 File: tar.info,  Node: create dir,  Prev: short create,  Up: create
1182
1183 2.6.5 Archiving Directories
1184 ---------------------------
1185
1186 You can archive a directory by specifying its directory name as a file
1187 name argument to `tar'.  The files in the directory will be archived
1188 relative to the working directory, and the directory will be re-created
1189 along with its contents when the archive is extracted.
1190
1191    To archive a directory, first move to its superior directory.  If you
1192 have followed the previous instructions in this tutorial, you should
1193 type:
1194
1195      $ cd ..
1196      $
1197
1198 This will put you into the directory which contains `practice', i.e.,
1199 your home directory.  Once in the superior directory, you can specify
1200 the subdirectory, `practice', as a file name argument.  To store
1201 `practice' in the new archive file `music.tar', type:
1202
1203      $ tar --create --verbose --file=music.tar practice
1204
1205 `tar' should output:
1206
1207      practice/
1208      practice/blues
1209      practice/folk
1210      practice/jazz
1211      practice/collection.tar
1212
1213    Note that the archive thus created is not in the subdirectory
1214 `practice', but rather in the current working directory--the directory
1215 from which `tar' was invoked.  Before trying to archive a directory
1216 from its superior directory, you should make sure you have write access
1217 to the superior directory itself, not only the directory you are trying
1218 archive with `tar'.  For example, you will probably not be able to
1219 store your home directory in an archive by invoking `tar' from the root
1220 directory; *Note absolute::.  (Note also that `collection.tar', the
1221 original archive file, has itself been archived.  `tar' will accept any
1222 file as a file to be archived, regardless of its content.  When
1223 `music.tar' is extracted, the archive file `collection.tar' will be
1224 re-written into the file system).
1225
1226    If you give `tar' a command such as
1227
1228      $ tar --create --file=foo.tar .
1229
1230 `tar' will report `tar: ./foo.tar is the archive; not dumped'.  This
1231 happens because `tar' creates the archive `foo.tar' in the current
1232 directory before putting any files into it.  Then, when `tar' attempts
1233 to add all the files in the directory `.' to the archive, it notices
1234 that the file `./foo.tar' is the same as the archive `foo.tar', and
1235 skips it.  (It makes no sense to put an archive into itself.)  GNU `tar'
1236 will continue in this case, and create the archive normally, except for
1237 the exclusion of that one file.  (_Please note:_ Other implementations
1238 of `tar' may not be so clever; they will enter an infinite loop when
1239 this happens, so you should not depend on this behavior unless you are
1240 certain you are running GNU `tar'.  In general, it is wise to always
1241 place the archive outside of the directory being dumped.
1242
1243 \1f
1244 File: tar.info,  Node: list,  Next: extract,  Prev: create,  Up: Tutorial
1245
1246 2.7 How to List Archives
1247 ========================
1248
1249 Frequently, you will find yourself wanting to determine exactly what a
1250 particular archive contains.  You can use the `--list' (`-t') operation
1251 to get the member names as they currently appear in the archive, as
1252 well as various attributes of the files at the time they were archived.
1253 For example, you can examine the archive `collection.tar' that you
1254 created in the last section with the command,
1255
1256      $ tar --list --file=collection.tar
1257
1258 The output of `tar' would then be:
1259
1260      blues
1261      folk
1262      jazz
1263
1264 The archive `bfiles.tar' would list as follows:
1265
1266      ./birds
1267      baboon
1268      ./box
1269
1270 Be sure to use a `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME') option just
1271 as with `--create' (`-c') to specify the name of the archive.
1272
1273    If you use the `--verbose' (`-v') option with `--list', then `tar'
1274 will print out a listing reminiscent of `ls -l', showing owner, file
1275 size, and so forth.  This output is described in detail in *note
1276 verbose member listing::.
1277
1278    If you had used `--verbose' (`-v') mode, the example above would
1279 look like:
1280
1281      $ tar --list --verbose --file=collection.tar folk
1282      -rw-r--r-- myself user 62 1990-05-23 10:55 folk
1283
1284    It is important to notice that the output of `tar --list --verbose'
1285 does not necessarily match that produced by `tar --create --verbose'
1286 while creating the archive.  It is because GNU `tar', unless told
1287 explicitly not to do so, removes some directory prefixes from file
1288 names before storing them in the archive (*Note absolute::, for more
1289 information).  In other words, in verbose mode GNU `tar' shows "file
1290 names" when creating an archive and "member names" when listing it.
1291 Consider this example:
1292
1293      $ tar cfv archive /etc/mail
1294      tar: Removing leading `/' from member names
1295      /etc/mail/
1296      /etc/mail/sendmail.cf
1297      /etc/mail/aliases
1298      $ tar tf archive
1299      etc/mail/
1300      etc/mail/sendmail.cf
1301      etc/mail/aliases
1302
1303    This default behavior can sometimes be inconvenient.  You can force
1304 GNU `tar' show member names when creating archive by supplying
1305 `--show-stored-names' option.
1306
1307 `--show-stored-names'
1308      Print member (as opposed to _file_) names when creating the
1309      archive.
1310
1311    You can specify one or more individual member names as arguments when
1312 using `list'.  In this case, `tar' will only list the names of members
1313 you identify.  For example, `tar --list --file=afiles.tar apple' would
1314 only print `apple'.
1315
1316    Because `tar' preserves file names, these must be specified as they
1317 appear in the archive (i.e., relative to the directory from which the
1318 archive was created).  Therefore, it is essential when specifying
1319 member names to `tar' that you give the exact member names.  For
1320 example, `tar --list --file=bfiles.tar birds' would produce an error
1321 message something like `tar: birds: Not found in archive', because
1322 there is no member named `birds', only one named `./birds'.  While the
1323 names `birds' and `./birds' name the same file, _member_ names by
1324 default are compared verbatim.
1325
1326    However, `tar --list --file=bfiles.tar baboon' would respond with
1327 `baboon', because this exact member name is in the archive file
1328 `bfiles.tar'.  If you are not sure of the exact file name, use
1329 "globbing patterns", for example:
1330
1331      $ tar --list --file=bfiles.tar --wildcards '*b*'
1332
1333 will list all members whose name contains `b'.  *Note wildcards::, for
1334 a detailed discussion of globbing patterns and related `tar' command
1335 line options.
1336
1337 * Menu:
1338
1339 * list dir::
1340
1341 \1f
1342 File: tar.info,  Node: list dir,  Up: list
1343
1344 Listing the Contents of a Stored Directory
1345 ------------------------------------------
1346
1347 To get information about the contents of an archived directory, use the
1348 directory name as a file name argument in conjunction with `--list'
1349 (`-t').  To find out file attributes, include the `--verbose' (`-v')
1350 option.
1351
1352    For example, to find out about files in the directory `practice', in
1353 the archive file `music.tar', type:
1354
1355      $ tar --list --verbose --file=music.tar practice
1356
1357    `tar' responds:
1358
1359      drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
1360      -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
1361      -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
1362      -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
1363      -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
1364
1365    When you use a directory name as a file name argument, `tar' acts on
1366 all the files (including sub-directories) in that directory.
1367
1368 \1f
1369 File: tar.info,  Node: extract,  Next: going further,  Prev: list,  Up: Tutorial
1370
1371 2.8 How to Extract Members from an Archive
1372 ==========================================
1373
1374      _(This message will disappear, once this node revised.)_
1375
1376 Creating an archive is only half the job--there is no point in storing
1377 files in an archive if you can't retrieve them.  The act of retrieving
1378 members from an archive so they can be used and manipulated as
1379 unarchived files again is called "extraction".  To extract files from
1380 an archive, use the `--extract' (`--get' or `-x') operation.  As with
1381 `--create', specify the name of the archive with `--file' (`-f')
1382 option. Extracting an archive does not modify the archive in any way;
1383 you can extract it multiple times if you want or need to.
1384
1385    Using `--extract', you can extract an entire archive, or specific
1386 files.  The files can be directories containing other files, or not.  As
1387 with `--create' (`-c') and `--list' (`-t'), you may use the short or the
1388 long form of the operation without affecting the performance.
1389
1390 * Menu:
1391
1392 * extracting archives::
1393 * extracting files::
1394 * extract dir::
1395 * extracting untrusted archives::
1396 * failing commands::
1397
1398 \1f
1399 File: tar.info,  Node: extracting archives,  Next: extracting files,  Up: extract
1400
1401 2.8.1 Extracting an Entire Archive
1402 ----------------------------------
1403
1404 To extract an entire archive, specify the archive file name only, with
1405 no individual file names as arguments.  For example,
1406
1407      $ tar -xvf collection.tar
1408
1409 produces this:
1410
1411      -rw-r--r-- me user     28 1996-10-18 16:31 jazz
1412      -rw-r--r-- me user     21 1996-09-23 16:44 blues
1413      -rw-r--r-- me user     20 1996-09-23 16:44 folk
1414
1415 \1f
1416 File: tar.info,  Node: extracting files,  Next: extract dir,  Prev: extracting archives,  Up: extract
1417
1418 2.8.2 Extracting Specific Files
1419 -------------------------------
1420
1421 To extract specific archive members, give their exact member names as
1422 arguments, as printed by `--list' (`-t').  If you had mistakenly
1423 deleted one of the files you had placed in the archive `collection.tar'
1424 earlier (say, `blues'), you can extract it from the archive without
1425 changing the archive's structure.  Its contents will be identical to
1426 the original file `blues' that you deleted.
1427
1428    First, make sure you are in the `practice' directory, and list the
1429 files in the directory.  Now, delete the file, `blues', and list the
1430 files in the directory again.
1431
1432    You can now extract the member `blues' from the archive file
1433 `collection.tar' like this:
1434
1435      $ tar --extract --file=collection.tar blues
1436
1437 If you list the files in the directory again, you will see that the file
1438 `blues' has been restored, with its original permissions, data
1439 modification times, and owner.(1)  (These parameters will be identical
1440 to those which the file had when you originally placed it in the
1441 archive; any changes you may have made before deleting the file from
1442 the file system, however, will _not_ have been made to the archive
1443 member.)  The archive file, `collection.tar', is the same as it was
1444 before you extracted `blues'.  You can confirm this by running `tar'
1445 with `--list' (`-t').
1446
1447    Remember that as with other operations, specifying the exact member
1448 name is important.  `tar --extract --file=bfiles.tar birds' will fail,
1449 because there is no member named `birds'.  To extract the member named
1450 `./birds', you must specify `tar --extract --file=bfiles.tar ./birds'.
1451 If you don't remember the exact member names, use `--list' (`-t') option
1452 (*note list::).  You can also extract those members that match a
1453 specific "globbing pattern".  For example, to extract from `bfiles.tar'
1454 all files that begin with `b', no matter their directory prefix, you
1455 could type:
1456
1457      $ tar -x -f bfiles.tar --wildcards --no-anchored 'b*'
1458
1459 Here, `--wildcards' instructs `tar' to treat command line arguments as
1460 globbing patterns and `--no-anchored' informs it that the patterns
1461 apply to member names after any `/' delimiter.  The use of globbing
1462 patterns is discussed in detail in *Note wildcards::.
1463
1464    You can extract a file to standard output by combining the above
1465 options with the `--to-stdout' (`-O') option (*note Writing to Standard
1466 Output::).
1467
1468    If you give the `--verbose' option, then `--extract' will print the
1469 names of the archive members as it extracts them.
1470
1471    ---------- Footnotes ----------
1472
1473    (1) This is only accidentally true, but not in general.  Whereas
1474 modification times are always restored, in most cases, one has to be
1475 root for restoring the owner, and use a special option for restoring
1476 permissions.  Here, it just happens that the restoring user is also the
1477 owner of the archived members, and that the current `umask' is
1478 compatible with original permissions.
1479
1480 \1f
1481 File: tar.info,  Node: extract dir,  Next: extracting untrusted archives,  Prev: extracting files,  Up: extract
1482
1483 2.8.3 Extracting Files that are Directories
1484 -------------------------------------------
1485
1486 Extracting directories which are members of an archive is similar to
1487 extracting other files.  The main difference to be aware of is that if
1488 the extracted directory has the same name as any directory already in
1489 the working directory, then files in the extracted directory will be
1490 placed into the directory of the same name.  Likewise, if there are
1491 files in the pre-existing directory with the same names as the members
1492 which you extract, the files from the extracted archive will replace
1493 the files already in the working directory (and possible
1494 subdirectories).  This will happen regardless of whether or not the
1495 files in the working directory were more recent than those extracted
1496 (there exist, however, special options that alter this behavior *note
1497 Writing::).
1498
1499    However, if a file was stored with a directory name as part of its
1500 file name, and that directory does not exist under the working
1501 directory when the file is extracted, `tar' will create the directory.
1502
1503    We can demonstrate how to use `--extract' to extract a directory
1504 file with an example.  Change to the `practice' directory if you
1505 weren't there, and remove the files `folk' and `jazz'.  Then, go back
1506 to the parent directory and extract the archive `music.tar'.  You may
1507 either extract the entire archive, or you may extract only the files
1508 you just deleted.  To extract the entire archive, don't give any file
1509 names as arguments after the archive name `music.tar'.  To extract only
1510 the files you deleted, use the following command:
1511
1512      $ tar -xvf music.tar practice/folk practice/jazz
1513      practice/folk
1514      practice/jazz
1515
1516 If you were to specify two `--verbose' (`-v') options, `tar' would have
1517 displayed more detail about the extracted files, as shown in the
1518 example below:
1519
1520      $ tar -xvvf music.tar practice/folk practice/jazz
1521      -rw-r--r-- me user     28 1996-10-18 16:31 practice/jazz
1522      -rw-r--r-- me user     20 1996-09-23 16:44 practice/folk
1523
1524 Because you created the directory with `practice' as part of the file
1525 names of each of the files by archiving the `practice' directory as
1526 `practice', you must give `practice' as part of the file names when you
1527 extract those files from the archive.
1528
1529 \1f
1530 File: tar.info,  Node: extracting untrusted archives,  Next: failing commands,  Prev: extract dir,  Up: extract
1531
1532 2.8.4 Extracting Archives from Untrusted Sources
1533 ------------------------------------------------
1534
1535 Extracting files from archives can overwrite files that already exist.
1536 If you receive an archive from an untrusted source, you should make a
1537 new directory and extract into that directory, so that you don't have
1538 to worry about the extraction overwriting one of your existing files.
1539 For example, if `untrusted.tar' came from somewhere else on the
1540 Internet, and you don't necessarily trust its contents, you can extract
1541 it as follows:
1542
1543      $ mkdir newdir
1544      $ cd newdir
1545      $ tar -xvf ../untrusted.tar
1546
1547    It is also a good practice to examine contents of the archive before
1548 extracting it, using `--list' (`-t') option, possibly combined with
1549 `--verbose' (`-v').
1550
1551 \1f
1552 File: tar.info,  Node: failing commands,  Prev: extracting untrusted archives,  Up: extract
1553
1554 2.8.5 Commands That Will Fail
1555 -----------------------------
1556
1557 Here are some sample commands you might try which will not work, and why
1558 they won't work.
1559
1560    If you try to use this command,
1561
1562      $ tar -xvf music.tar folk jazz
1563
1564 you will get the following response:
1565
1566      tar: folk: Not found in archive
1567      tar: jazz: Not found in archive
1568      $
1569
1570 This is because these files were not originally _in_ the parent
1571 directory `..', where the archive is located; they were in the
1572 `practice' directory, and their file names reflect this:
1573
1574      $ tar -tvf music.tar
1575      practice/folk
1576      practice/jazz
1577      practice/rock
1578
1579 Likewise, if you try to use this command,
1580
1581      $ tar -tvf music.tar folk jazz
1582
1583 you would get a similar response.  Members with those names are not in
1584 the archive.  You must use the correct member names, or wildcards, in
1585 order to extract the files from the archive.
1586
1587    If you have forgotten the correct names of the files in the archive,
1588 use `tar --list --verbose' to list them correctly.
1589
1590 \1f
1591 File: tar.info,  Node: going further,  Prev: extract,  Up: Tutorial
1592
1593 2.9 Going Further Ahead in this Manual
1594 ======================================
1595
1596      _(This message will disappear, once this node revised.)_
1597
1598 \1f
1599 File: tar.info,  Node: tar invocation,  Next: operations,  Prev: Tutorial,  Up: Top
1600
1601 3 Invoking GNU `tar'
1602 ********************
1603
1604      _(This message will disappear, once this node revised.)_
1605
1606 This chapter is about how one invokes the GNU `tar' command, from the
1607 command synopsis (*note Synopsis::).  There are numerous options, and
1608 many styles for writing them.  One mandatory option specifies the
1609 operation `tar' should perform (*note Operation Summary::), other
1610 options are meant to detail how this operation should be performed
1611 (*note Option Summary::).  Non-option arguments are not always
1612 interpreted the same way, depending on what the operation is.
1613
1614    You will find in this chapter everything about option styles and
1615 rules for writing them (*note Styles::).  On the other hand, operations
1616 and options are fully described elsewhere, in other chapters.  Here,
1617 you will find only synthetic descriptions for operations and options,
1618 together with pointers to other parts of the `tar' manual.
1619
1620    Some options are so special they are fully described right in this
1621 chapter.  They have the effect of inhibiting the normal operation of
1622 `tar' or else, they globally alter the amount of feedback the user
1623 receives about what is going on.  These are the `--help' and
1624 `--version' (*note help::), `--verbose' (*note verbose::) and
1625 `--interactive' options (*note interactive::).
1626
1627 * Menu:
1628
1629 * Synopsis::
1630 * using tar options::
1631 * Styles::
1632 * All Options::
1633 * help::
1634 * defaults::
1635 * verbose::
1636 * checkpoints::
1637 * interactive::
1638
1639 \1f
1640 File: tar.info,  Node: Synopsis,  Next: using tar options,  Up: tar invocation
1641
1642 3.1 General Synopsis of `tar'
1643 =============================
1644
1645 The GNU `tar' program is invoked as either one of:
1646
1647      tar OPTION... [NAME]...
1648      tar LETTER... [ARGUMENT]... [OPTION]... [NAME]...
1649
1650    The second form is for when old options are being used.
1651
1652    You can use `tar' to store files in an archive, to extract them from
1653 an archive, and to do other types of archive manipulation.  The primary
1654 argument to `tar', which is called the "operation", specifies which
1655 action to take.  The other arguments to `tar' are either "options",
1656 which change the way `tar' performs an operation, or file names or
1657 archive members, which specify the files or members `tar' is to act on.
1658
1659    You can actually type in arguments in any order, even if in this
1660 manual the options always precede the other arguments, to make examples
1661 easier to understand.  Further, the option stating the main operation
1662 mode (the `tar' main command) is usually given first.
1663
1664    Each NAME in the synopsis above is interpreted as an archive member
1665 name when the main command is one of `--compare' (`--diff', `-d'),
1666 `--delete', `--extract' (`--get', `-x'), `--list' (`-t') or `--update'
1667 (`-u').  When naming archive members, you must give the exact name of
1668 the member in the archive, as it is printed by `--list'.  For
1669 `--append' (`-r') and `--create' (`-c'), these NAME arguments specify
1670 the names of either files or directory hierarchies to place in the
1671 archive.  These files or hierarchies should already exist in the file
1672 system, prior to the execution of the `tar' command.
1673
1674    `tar' interprets relative file names as being relative to the
1675 working directory.  `tar' will make all file names relative (by
1676 removing leading slashes when archiving or restoring files), unless you
1677 specify otherwise (using the `--absolute-names' option).  *Note
1678 absolute::, for more information about `--absolute-names'.
1679
1680    If you give the name of a directory as either a file name or a member
1681 name, then `tar' acts recursively on all the files and directories
1682 beneath that directory.  For example, the name `/' identifies all the
1683 files in the file system to `tar'.
1684
1685    The distinction between file names and archive member names is
1686 especially important when shell globbing is used, and sometimes a
1687 source of confusion for newcomers.  *Note wildcards::, for more
1688 information about globbing.  The problem is that shells may only glob
1689 using existing files in the file system.  Only `tar' itself may glob on
1690 archive members, so when needed, you must ensure that wildcard
1691 characters reach `tar' without being interpreted by the shell first.
1692 Using a backslash before `*' or `?', or putting the whole argument
1693 between quotes, is usually sufficient for this.
1694
1695    Even if NAMEs are often specified on the command line, they can also
1696 be read from a text file in the file system, using the
1697 `--files-from=FILE-OF-NAMES' (`-T FILE-OF-NAMES') option.
1698
1699    If you don't use any file name arguments, `--append' (`-r'),
1700 `--delete' and `--concatenate' (`--catenate', `-A') will do nothing,
1701 while `--create' (`-c') will usually yield a diagnostic and inhibit
1702 `tar' execution.  The other operations of `tar' (`--list', `--extract',
1703 `--compare', and `--update') will act on the entire contents of the
1704 archive.
1705
1706    Besides successful exits, GNU `tar' may fail for many reasons.  Some
1707 reasons correspond to bad usage, that is, when the `tar' command is
1708 improperly written.  Errors may be encountered later, while
1709 encountering an error processing the archive or the files.  Some errors
1710 are recoverable, in which case the failure is delayed until `tar' has
1711 completed all its work.  Some errors are such that it would not
1712 meaningful, or at least risky, to continue processing: `tar' then
1713 aborts processing immediately.  All abnormal exits, whether immediate
1714 or delayed, should always be clearly diagnosed on `stderr', after a
1715 line stating the nature of the error.
1716
1717    Possible exit codes of GNU `tar' are summarized in the following
1718 table:
1719
1720 0
1721      `Successful termination'.
1722
1723 1
1724      `Some files differ'.  If tar was invoked with `--compare'
1725      (`--diff', `-d') command line option, this means that some files
1726      in the archive differ from their disk counterparts (*note
1727      compare::).  If tar was given `--create', `--append' or `--update'
1728      option, this exit code means that some files were changed while
1729      being archived and so the resulting archive does not contain the
1730      exact copy of the file set.
1731
1732 2
1733      `Fatal error'.  This means that some fatal, unrecoverable error
1734      occurred.
1735
1736    If `tar' has invoked a subprocess and that subprocess exited with a
1737 nonzero exit code, `tar' exits with that code as well.  This can
1738 happen, for example, if `tar' was given some compression option (*note
1739 gzip::) and the external compressor program failed.  Another example is
1740 `rmt' failure during backup to the remote device (*note Remote Tape
1741 Server::).
1742
1743 \1f
1744 File: tar.info,  Node: using tar options,  Next: Styles,  Prev: Synopsis,  Up: tar invocation
1745
1746 3.2 Using `tar' Options
1747 =======================
1748
1749 GNU `tar' has a total of eight operating modes which allow you to
1750 perform a variety of tasks.  You are required to choose one operating
1751 mode each time you employ the `tar' program by specifying one, and only
1752 one operation as an argument to the `tar' command (two lists of four
1753 operations each may be found at *note frequent operations:: and *note
1754 Operations::).  Depending on circumstances, you may also wish to
1755 customize how the chosen operating mode behaves.  For example, you may
1756 wish to change the way the output looks, or the format of the files
1757 that you wish to archive may require you to do something special in
1758 order to make the archive look right.
1759
1760    You can customize and control `tar''s performance by running `tar'
1761 with one or more options (such as `--verbose' (`-v'), which we used in
1762 the tutorial).  As we said in the tutorial, "options" are arguments to
1763 `tar' which are (as their name suggests) optional. Depending on the
1764 operating mode, you may specify one or more options. Different options
1765 will have different effects, but in general they all change details of
1766 the operation, such as archive format, archive name, or level of user
1767 interaction.  Some options make sense with all operating modes, while
1768 others are meaningful only with particular modes. You will likely use
1769 some options frequently, while you will only use others infrequently, or
1770 not at all.  (A full list of options is available in *note All
1771 Options::.)
1772
1773    The `TAR_OPTIONS' environment variable specifies default options to
1774 be placed in front of any explicit options.  For example, if
1775 `TAR_OPTIONS' is `-v --unlink-first', `tar' behaves as if the two
1776 options `-v' and `--unlink-first' had been specified before any
1777 explicit options.  Option specifications are separated by whitespace.
1778 A backslash escapes the next character, so it can be used to specify an
1779 option containing whitespace or a backslash.
1780
1781    Note that `tar' options are case sensitive.  For example, the
1782 options `-T' and `-t' are different; the first requires an argument for
1783 stating the name of a file providing a list of NAMEs, while the second
1784 does not require an argument and is another way to write `--list'
1785 (`-t').
1786
1787    In addition to the eight operations, there are many options to
1788 `tar', and three different styles for writing both: long (mnemonic)
1789 form, short form, and old style.  These styles are discussed below.
1790 Both the options and the operations can be written in any of these three
1791 styles.
1792
1793 \1f
1794 File: tar.info,  Node: Styles,  Next: All Options,  Prev: using tar options,  Up: tar invocation
1795
1796 3.3 The Three Option Styles
1797 ===========================
1798
1799 There are three styles for writing operations and options to the command
1800 line invoking `tar'.  The different styles were developed at different
1801 times during the history of `tar'.  These styles will be presented
1802 below, from the most recent to the oldest.
1803
1804    Some options must take an argument.  (For example, `--file' (`-f'))
1805 takes the name of an archive file as an argument.  If you do not supply
1806 an archive file name, `tar' will use a default, but this can be
1807 confusing; thus, we recommend that you always supply a specific archive
1808 file name.)  Where you _place_ the arguments generally depends on which
1809 style of options you choose.  We will detail specific information
1810 relevant to each option style in the sections on the different option
1811 styles, below.  The differences are subtle, yet can often be very
1812 important; incorrect option placement can cause you to overwrite a
1813 number of important files.  We urge you to note these differences, and
1814 only use the option style(s) which makes the most sense to you until
1815 you feel comfortable with the others.
1816
1817    Some options _may_ take an argument.  Such options may have at most
1818 long and short forms, they do not have old style equivalent.  The rules
1819 for specifying an argument for such options are stricter than those for
1820 specifying mandatory arguments.  Please, pay special attention to them.
1821
1822 * Menu:
1823
1824 * Long Options::                Long Option Style
1825 * Short Options::               Short Option Style
1826 * Old Options::                 Old Option Style
1827 * Mixing::                      Mixing Option Styles
1828
1829 \1f
1830 File: tar.info,  Node: Long Options,  Next: Short Options,  Up: Styles
1831
1832 3.3.1 Long Option Style
1833 -----------------------
1834
1835 Each option has at least one "long" (or "mnemonic") name starting with
1836 two dashes in a row, e.g., `--list'.  The long names are more clear than
1837 their corresponding short or old names.  It sometimes happens that a
1838 single long option has many different names which are synonymous, such
1839 as `--compare' and `--diff'.  In addition, long option names can be
1840 given unique abbreviations.  For example, `--cre' can be used in place
1841 of `--create' because there is no other long option which begins with
1842 `cre'.  (One way to find this out is by trying it and seeing what
1843 happens; if a particular abbreviation could represent more than one
1844 option, `tar' will tell you that that abbreviation is ambiguous and
1845 you'll know that that abbreviation won't work.  You may also choose to
1846 run `tar --help' to see a list of options.  Be aware that if you run
1847 `tar' with a unique abbreviation for the long name of an option you
1848 didn't want to use, you are stuck; `tar' will perform the command as
1849 ordered.)
1850
1851    Long options are meant to be obvious and easy to remember, and their
1852 meanings are generally easier to discern than those of their
1853 corresponding short options (see below).  For example:
1854
1855      $ tar --create --verbose --blocking-factor=20 --file=/dev/rmt0
1856
1857 gives a fairly good set of hints about what the command does, even for
1858 those not fully acquainted with `tar'.
1859
1860    Long options which require arguments take those arguments
1861 immediately following the option name.  There are two ways of
1862 specifying a mandatory argument.  It can be separated from the option
1863 name either by an equal sign, or by any amount of white space
1864 characters.  For example, the `--file' option (which tells the name of
1865 the `tar' archive) is given a file such as `archive.tar' as argument by
1866 using any of the following notations: `--file=archive.tar' or `--file
1867 archive.tar'.
1868
1869    In contrast, optional arguments must always be introduced using an
1870 equal sign.  For example, the `--backup' option takes an optional
1871 argument specifying backup type.  It must be used as
1872 `--backup=BACKUP-TYPE'.
1873
1874 \1f
1875 File: tar.info,  Node: Short Options,  Next: Old Options,  Prev: Long Options,  Up: Styles
1876
1877 3.3.2 Short Option Style
1878 ------------------------
1879
1880 Most options also have a "short option" name.  Short options start with
1881 a single dash, and are followed by a single character, e.g., `-t'
1882 (which is equivalent to `--list').  The forms are absolutely identical
1883 in function; they are interchangeable.
1884
1885    The short option names are faster to type than long option names.
1886
1887    Short options which require arguments take their arguments
1888 immediately following the option, usually separated by white space.  It
1889 is also possible to stick the argument right after the short option
1890 name, using no intervening space.  For example, you might write
1891 `-f archive.tar' or `-farchive.tar' instead of using
1892 `--file=archive.tar'.  Both `--file=ARCHIVE-NAME' and `-f ARCHIVE-NAME'
1893 denote the option which indicates a specific archive, here named
1894 `archive.tar'.
1895
1896    Short options which take optional arguments take their arguments
1897 immediately following the option letter, _without any intervening white
1898 space characters_.
1899
1900    Short options' letters may be clumped together, but you are not
1901 required to do this (as compared to old options; see below).  When
1902 short options are clumped as a set, use one (single) dash for them all,
1903 e.g., ``tar' -cvf'.  Only the last option in such a set is allowed to
1904 have an argument(1).
1905
1906    When the options are separated, the argument for each option which
1907 requires an argument directly follows that option, as is usual for Unix
1908 programs.  For example:
1909
1910      $ tar -c -v -b 20 -f /dev/rmt0
1911
1912    If you reorder short options' locations, be sure to move any
1913 arguments that belong to them.  If you do not move the arguments
1914 properly, you may end up overwriting files.
1915
1916    ---------- Footnotes ----------
1917
1918    (1) Clustering many options, the last of which has an argument, is a
1919 rather opaque way to write options.  Some wonder if GNU `getopt' should
1920 not even be made helpful enough for considering such usages as invalid.
1921
1922 \1f
1923 File: tar.info,  Node: Old Options,  Next: Mixing,  Prev: Short Options,  Up: Styles
1924
1925 3.3.3 Old Option Style
1926 ----------------------
1927
1928      _(This message will disappear, once this node revised.)_
1929
1930 Like short options, "old options" are single letters.  However, old
1931 options must be written together as a single clumped set, without
1932 spaces separating them or dashes preceding them(1).  This set of
1933 letters must be the first to appear on the command line, after the
1934 `tar' program name and some white space; old options cannot appear
1935 anywhere else.  The letter of an old option is exactly the same letter
1936 as the corresponding short option.  For example, the old option `t' is
1937 the same as the short option `-t', and consequently, the same as the
1938 long option `--list'.  So for example, the command `tar cv' specifies
1939 the option `-v' in addition to the operation `-c'.
1940
1941    When options that need arguments are given together with the command,
1942 all the associated arguments follow, in the same order as the options.
1943 Thus, the example given previously could also be written in the old
1944 style as follows:
1945
1946      $ tar cvbf 20 /dev/rmt0
1947
1948 Here, `20' is the argument of `-b' and `/dev/rmt0' is the argument of
1949 `-f'.
1950
1951    On the other hand, this old style syntax makes it difficult to match
1952 option letters with their corresponding arguments, and is often
1953 confusing.  In the command `tar cvbf 20 /dev/rmt0', for example, `20'
1954 is the argument for `-b', `/dev/rmt0' is the argument for `-f', and
1955 `-v' does not have a corresponding argument.  Even using short options
1956 like in `tar -c -v -b 20 -f /dev/rmt0' is clearer, putting all
1957 arguments next to the option they pertain to.
1958
1959    If you want to reorder the letters in the old option argument, be
1960 sure to reorder any corresponding argument appropriately.
1961
1962    This old way of writing `tar' options can surprise even experienced
1963 users.  For example, the two commands:
1964
1965      tar cfz archive.tar.gz file
1966      tar -cfz archive.tar.gz file
1967
1968 are quite different.  The first example uses `archive.tar.gz' as the
1969 value for option `f' and recognizes the option `z'.  The second
1970 example, however, uses `z' as the value for option `f' -- probably not
1971 what was intended.
1972
1973    Old options are kept for compatibility with old versions of `tar'.
1974
1975    This second example could be corrected in many ways, among which the
1976 following are equivalent:
1977
1978      tar -czf archive.tar.gz file
1979      tar -cf archive.tar.gz -z file
1980      tar cf archive.tar.gz -z file
1981
1982    As far as we know, all `tar' programs, GNU and non-GNU, support old
1983 options.  GNU `tar' supports them not only for historical reasons, but
1984 also because many people are used to them.  For compatibility with Unix
1985 `tar', the first argument is always treated as containing command and
1986 option letters even if it doesn't start with `-'.  Thus, `tar c' is
1987 equivalent to `tar -c': both of them specify the `--create' (`-c')
1988 command to create an archive.
1989
1990    ---------- Footnotes ----------
1991
1992    (1) Beware that if you precede options with a dash, you are
1993 announcing the short option style instead of the old option style;
1994 short options are decoded differently.
1995
1996 \1f
1997 File: tar.info,  Node: Mixing,  Prev: Old Options,  Up: Styles
1998
1999 3.3.4 Mixing Option Styles
2000 --------------------------
2001
2002 All three styles may be intermixed in a single `tar' command, so long
2003 as the rules for each style are fully respected(1).  Old style options
2004 and either of the modern styles of options may be mixed within a single
2005 `tar' command.  However, old style options must be introduced as the
2006 first arguments only, following the rule for old options (old options
2007 must appear directly after the `tar' command and some white space).
2008 Modern options may be given only after all arguments to the old options
2009 have been collected.  If this rule is not respected, a modern option
2010 might be falsely interpreted as the value of the argument to one of the
2011 old style options.
2012
2013    For example, all the following commands are wholly equivalent, and
2014 illustrate the many combinations and orderings of option styles.
2015
2016      tar --create --file=archive.tar
2017      tar --create -f archive.tar
2018      tar --create -farchive.tar
2019      tar --file=archive.tar --create
2020      tar --file=archive.tar -c
2021      tar -c --file=archive.tar
2022      tar -c -f archive.tar
2023      tar -c -farchive.tar
2024      tar -cf archive.tar
2025      tar -cfarchive.tar
2026      tar -f archive.tar --create
2027      tar -f archive.tar -c
2028      tar -farchive.tar --create
2029      tar -farchive.tar -c
2030      tar c --file=archive.tar
2031      tar c -f archive.tar
2032      tar c -farchive.tar
2033      tar cf archive.tar
2034      tar f archive.tar --create
2035      tar f archive.tar -c
2036      tar fc archive.tar
2037
2038    On the other hand, the following commands are _not_ equivalent to
2039 the previous set:
2040
2041      tar -f -c archive.tar
2042      tar -fc archive.tar
2043      tar -fcarchive.tar
2044      tar -farchive.tarc
2045      tar cfarchive.tar
2046
2047 These last examples mean something completely different from what the
2048 user intended (judging based on the example in the previous set which
2049 uses long options, whose intent is therefore very clear).  The first
2050 four specify that the `tar' archive would be a file named `-c', `c',
2051 `carchive.tar' or `archive.tarc', respectively.  The first two examples
2052 also specify a single non-option, NAME argument having the value
2053 `archive.tar'.  The last example contains only old style option letters
2054 (repeating option `c' twice), not all of which are meaningful (eg., `.',
2055 `h', or `i'), with no argument value.
2056
2057    ---------- Footnotes ----------
2058
2059    (1) Before GNU `tar' version 1.11.6, a bug prevented intermixing old
2060 style options with long options in some cases.
2061
2062 \1f
2063 File: tar.info,  Node: All Options,  Next: help,  Prev: Styles,  Up: tar invocation
2064
2065 3.4 All `tar' Options
2066 =====================
2067
2068 The coming manual sections contain an alphabetical listing of all `tar'
2069 operations and options, with brief descriptions and cross references to
2070 more in-depth explanations in the body of the manual.  They also
2071 contain an alphabetically arranged table of the short option forms with
2072 their corresponding long option.  You can use this table as a reference
2073 for deciphering `tar' commands in scripts.
2074
2075 * Menu:
2076
2077 * Operation Summary::
2078 * Option Summary::
2079 * Short Option Summary::
2080
2081 \1f
2082 File: tar.info,  Node: Operation Summary,  Next: Option Summary,  Up: All Options
2083
2084 3.4.1 Operations
2085 ----------------
2086
2087 `--append'
2088 `-r'
2089      Appends files to the end of the archive.  *Note append::.
2090
2091 `--catenate'
2092 `-A'
2093      Same as `--concatenate'.  *Note concatenate::.
2094
2095 `--compare'
2096 `-d'
2097      Compares archive members with their counterparts in the file
2098      system, and reports differences in file size, mode, owner,
2099      modification date and contents.  *Note compare::.
2100
2101 `--concatenate'
2102 `-A'
2103      Appends other `tar' archives to the end of the archive.  *Note
2104      concatenate::.
2105
2106 `--create'
2107 `-c'
2108      Creates a new `tar' archive.  *Note create::.
2109
2110 `--delete'
2111      Deletes members from the archive.  Don't try this on a archive on a
2112      tape!  *Note delete::.
2113
2114 `--diff'
2115 `-d'
2116      Same `--compare'.  *Note compare::.
2117
2118 `--extract'
2119 `-x'
2120      Extracts members from the archive into the file system.  *Note
2121      extract::.
2122
2123 `--get'
2124 `-x'
2125      Same as `--extract'.  *Note extract::.
2126
2127 `--list'
2128 `-t'
2129      Lists the members in an archive.  *Note list::.
2130
2131 `--update'
2132 `-u'
2133      Adds files to the end of the archive, but only if they are newer
2134      than their counterparts already in the archive, or if they do not
2135      already exist in the archive. *Note update::.
2136
2137
2138 \1f
2139 File: tar.info,  Node: Option Summary,  Next: Short Option Summary,  Prev: Operation Summary,  Up: All Options
2140
2141 3.4.2 `tar' Options
2142 -------------------
2143
2144 `--absolute-names'
2145 `-P'
2146      Normally when creating an archive, `tar' strips an initial `/'
2147      from member names.  This option disables that behavior.  *Note
2148      absolute::.
2149
2150 `--after-date'
2151      (See `--newer', *note after::)
2152
2153 `--anchored'
2154      A pattern must match an initial subsequence of the name's
2155      components.  *Note controlling pattern-matching::.
2156
2157 `--atime-preserve'
2158 `--atime-preserve=replace'
2159 `--atime-preserve=system'
2160      Attempt to preserve the access time of files when reading them.
2161      This option currently is effective only on files that you own,
2162      unless you have superuser privileges.
2163
2164      `--atime-preserve=replace' remembers the access time of a file
2165      before reading it, and then restores the access time afterwards.
2166      This may cause problems if other programs are reading the file at
2167      the same time, as the times of their accesses will be lost.  On
2168      most platforms restoring the access time also requires `tar' to
2169      restore the data modification time too, so this option may also
2170      cause problems if other programs are writing the file at the same
2171      time.  (Tar attempts to detect this situation, but cannot do so
2172      reliably due to race conditions.)  Worse, on most platforms
2173      restoring the access time also updates the status change time,
2174      which means that this option is incompatible with incremental
2175      backups.
2176
2177      `--atime-preserve=system' avoids changing time stamps on files,
2178      without interfering with time stamp updates caused by other
2179      programs, so it works better with incremental backups.  However,
2180      it requires a special `O_NOATIME' option from the underlying
2181      operating and file system implementation, and it also requires
2182      that searching directories does not update their access times.  As
2183      of this writing (November 2005) this works only with Linux, and
2184      only with Linux kernels 2.6.8 and later.  Worse, there is
2185      currently no reliable way to know whether this feature actually
2186      works.  Sometimes `tar' knows that it does not work, and if you use
2187      `--atime-preserve=system' then `tar' complains and exits right
2188      away.  But other times `tar' might think that the option works
2189      when it actually does not.
2190
2191      Currently `--atime-preserve' with no operand defaults to
2192      `--atime-preserve=replace', but this may change in the future as
2193      support for `--atime-preserve=system' improves.
2194
2195      If your operating system does not support
2196      `--atime-preserve=system', you might be able to preserve access
2197      times reliably by by using the `mount' command.  For example, you
2198      can mount the file system read-only, or access the file system via
2199      a read-only loopback mount, or use the `noatime' mount option
2200      available on some systems.  However, mounting typically requires
2201      superuser privileges and can be a pain to manage.
2202
2203 `--auto-compress'
2204 `-a'
2205      During a `--create' operation, enables automatic compressed format
2206      recognition based on the archive suffix.  The effect of this
2207      option is cancelled by `--no-auto-compress'.  *Note gzip::.
2208
2209 `--backup=BACKUP-TYPE'
2210      Rather than deleting files from the file system, `tar' will back
2211      them up using simple or numbered backups, depending upon
2212      BACKUP-TYPE.  *Note backup::.
2213
2214 `--block-number'
2215 `-R'
2216      With this option present, `tar' prints error messages for read
2217      errors with the block number in the archive file.  *Note
2218      block-number::.
2219
2220 `--blocking-factor=BLOCKING'
2221 `-b BLOCKING'
2222      Sets the blocking factor `tar' uses to BLOCKING x 512 bytes per
2223      record.  *Note Blocking Factor::.
2224
2225 `--bzip2'
2226 `-j'
2227      This option tells `tar' to read or write archives through `bzip2'.
2228      *Note gzip::.
2229
2230 `--check-device'
2231      Check device numbers when creating a list of modified files for
2232      incremental archiving.  This is the default.  *Note device
2233      numbers::, for a detailed description.
2234
2235 `--checkpoint[=NUMBER]'
2236      This option directs `tar' to print periodic checkpoint messages as
2237      it reads through the archive.  It is intended for when you want a
2238      visual indication that `tar' is still running, but don't want to
2239      see `--verbose' output.  You can also instruct `tar' to execute a
2240      list of actions on each checkpoint, see `--checklist-action'
2241      below.  For a detailed description, see *note checkpoints::.
2242
2243 `--checkpoint-action=ACTION'
2244      Instruct `tar' to execute an action upon hitting a breakpoint.
2245      Here we give only a brief outline.  *Note checkpoints::, for a
2246      complete description.
2247
2248      The ACTION argument can be one of the following:
2249
2250     bell
2251           Produce an audible bell on the console.
2252
2253     dot
2254     .
2255           Print a single dot on the standard listing stream.
2256
2257     echo
2258           Display a textual message on the standard error, with the
2259           status and number of the checkpoint.  This is the default.
2260
2261     echo=STRING
2262           Display STRING on the standard error.  Before output, the
2263           string is subject to meta-character expansion.
2264
2265     exec=COMMAND
2266           Execute the given COMMAND.
2267
2268     sleep=TIME
2269           Wait for TIME seconds.
2270
2271     ttyout=STRING
2272           Output STRING on the current console (`/dev/tty').
2273
2274      Several `--checkpoint-action' options can be specified.  The
2275      supplied actions will be executed in order of their appearance in
2276      the command line.
2277
2278      Using `--checkpoint-action' without `--checkpoint' assumes default
2279      checkpoint frequency of one checkpoint per 10 records.
2280
2281 `--check-links'
2282 `-l'
2283      If this option was given, `tar' will check the number of links
2284      dumped for each processed file.  If this number does not match the
2285      total number of hard links for the file, a warning message will be
2286      output (1).
2287
2288      *Note hard links::.
2289
2290 `--compress'
2291 `--uncompress'
2292 `-Z'
2293      `tar' will use the `compress' program when reading or writing the
2294      archive.  This allows you to directly act on archives while saving
2295      space.  *Note gzip::.
2296
2297 `--confirmation'
2298      (See `--interactive'.)  *Note interactive::.
2299
2300 `--delay-directory-restore'
2301      Delay setting modification times and permissions of extracted
2302      directories until the end of extraction. *Note Directory
2303      Modification Times and Permissions::.
2304
2305 `--dereference'
2306 `-h'
2307      When creating a `tar' archive, `tar' will archive the file that a
2308      symbolic link points to, rather than archiving the symlink.  *Note
2309      dereference::.
2310
2311 `--directory=DIR'
2312 `-C DIR'
2313      When this option is specified, `tar' will change its current
2314      directory to DIR before performing any operations.  When this
2315      option is used during archive creation, it is order sensitive.
2316      *Note directory::.
2317
2318 `--exclude=PATTERN'
2319      When performing operations, `tar' will skip files that match
2320      PATTERN.  *Note exclude::.
2321
2322 `--exclude-from=FILE'
2323 `-X FILE'
2324      Similar to `--exclude', except `tar' will use the list of patterns
2325      in the file FILE.  *Note exclude::.
2326
2327 `--exclude-caches'
2328      Exclude from dump any directory containing a valid cache directory
2329      tag file, but still dump the directory node and the tag file
2330      itself.
2331
2332      *Note exclude::.
2333
2334 `--exclude-caches-under'
2335      Exclude from dump any directory containing a valid cache directory
2336      tag file, but still dump the directory node itself.
2337
2338      *Note exclude::.
2339
2340 `--exclude-caches-all'
2341      Exclude from dump any directory containing a valid cache directory
2342      tag file.  *Note exclude::.
2343
2344 `--exclude-tag=FILE'
2345      Exclude from dump any directory containing file named FILE, but
2346      dump the directory node and FILE itself.  *Note exclude::.
2347
2348 `--exclude-tag-under=FILE'
2349      Exclude from dump the contents of any directory containing file
2350      named FILE, but dump the directory node itself.  *Note exclude::.
2351
2352 `--exclude-tag-all=FILE'
2353      Exclude from dump any directory containing file named FILE.  *Note
2354      exclude::.
2355
2356 `--exclude-vcs'
2357      Exclude from dump directories and files, that are internal for some
2358      widely used version control systems.
2359
2360      *Note exclude::.
2361
2362 `--file=ARCHIVE'
2363 `-f ARCHIVE'
2364      `tar' will use the file ARCHIVE as the `tar' archive it performs
2365      operations on, rather than `tar''s compilation dependent default.
2366      *Note file tutorial::.
2367
2368 `--files-from=FILE'
2369 `-T FILE'
2370      `tar' will use the contents of FILE as a list of archive members
2371      or files to operate on, in addition to those specified on the
2372      command-line.  *Note files::.
2373
2374 `--force-local'
2375      Forces `tar' to interpret the file name given to `--file' as a
2376      local file, even if it looks like a remote tape drive name.  *Note
2377      local and remote archives::.
2378
2379 `--format=FORMAT'
2380 `-H FORMAT'
2381      Selects output archive format.  FORMAT may be one of the following:
2382
2383     `v7'
2384           Creates an archive that is compatible with Unix V7 `tar'.
2385
2386     `oldgnu'
2387           Creates an archive that is compatible with GNU `tar' version
2388           1.12 or earlier.
2389
2390     `gnu'
2391           Creates archive in GNU tar 1.13 format.  Basically it is the
2392           same as `oldgnu' with the only difference in the way it
2393           handles long numeric fields.
2394
2395     `ustar'
2396           Creates a POSIX.1-1988 compatible archive.
2397
2398     `posix'
2399           Creates a POSIX.1-2001 archive.
2400
2401
2402      *Note Formats::, for a detailed discussion of these formats.
2403
2404 `--group=GROUP'
2405      Files added to the `tar' archive will have a group ID of GROUP,
2406      rather than the group from the source file.  GROUP is first decoded
2407      as a group symbolic name, but if this interpretation fails, it has
2408      to be a decimal numeric group ID.  *Note override::.
2409
2410      Also see the comments for the `--owner=USER' option.
2411
2412 `--gzip'
2413 `--gunzip'
2414 `--ungzip'
2415 `-z'
2416      This option tells `tar' to read or write archives through `gzip',
2417      allowing `tar' to directly operate on several kinds of compressed
2418      archives transparently.  *Note gzip::.
2419
2420 `--hard-dereference'
2421      When creating an archive, dereference hard links and store the
2422      files they refer to, instead of creating usual hard link members.
2423
2424      *Note hard links::.
2425
2426 `--help'
2427 `-?'
2428      `tar' will print out a short message summarizing the operations and
2429      options to `tar' and exit. *Note help::.
2430
2431 `--ignore-case'
2432      Ignore case when matching member or file names with patterns.
2433      *Note controlling pattern-matching::.
2434
2435 `--ignore-command-error'
2436      Ignore exit codes of subprocesses. *Note Writing to an External
2437      Program::.
2438
2439 `--ignore-failed-read'
2440      Do not exit unsuccessfully merely because an unreadable file was
2441      encountered.  *Note Reading::.
2442
2443 `--ignore-zeros'
2444 `-i'
2445      With this option, `tar' will ignore zeroed blocks in the archive,
2446      which normally signals EOF.  *Note Reading::.
2447
2448 `--incremental'
2449 `-G'
2450      Informs `tar' that it is working with an old GNU-format
2451      incremental backup archive.  It is intended primarily for
2452      backwards compatibility only.  *Note Incremental Dumps::, for a
2453      detailed discussion of incremental archives.
2454
2455 `--index-file=FILE'
2456      Send verbose output to FILE instead of to standard output.
2457
2458 `--info-script=SCRIPT-FILE'
2459 `--new-volume-script=SCRIPT-FILE'
2460 `-F SCRIPT-FILE'
2461      When `tar' is performing multi-tape backups, SCRIPT-FILE is run at
2462      the end of each tape.  If SCRIPT-FILE exits with nonzero status,
2463      `tar' fails immediately.  *Note info-script::, for a detailed
2464      discussion of SCRIPT-FILE.
2465
2466 `--interactive'
2467 `--confirmation'
2468 `-w'
2469      Specifies that `tar' should ask the user for confirmation before
2470      performing potentially destructive options, such as overwriting
2471      files.  *Note interactive::.
2472
2473 `--keep-newer-files'
2474      Do not replace existing files that are newer than their archive
2475      copies when extracting files from an archive.
2476
2477 `--keep-old-files'
2478 `-k'
2479      Do not overwrite existing files when extracting files from an
2480      archive.  *Note Keep Old Files::.
2481
2482 `--label=NAME'
2483 `-V NAME'
2484      When creating an archive, instructs `tar' to write NAME as a name
2485      record in the archive.  When extracting or listing archives, `tar'
2486      will only operate on archives that have a label matching the
2487      pattern specified in NAME.  *Note Tape Files::.
2488
2489 `--listed-incremental=SNAPSHOT-FILE'
2490 `-g SNAPSHOT-FILE'
2491      During a `--create' operation, specifies that the archive that
2492      `tar' creates is a new GNU-format incremental backup, using
2493      SNAPSHOT-FILE to determine which files to backup.  With other
2494      operations, informs `tar' that the archive is in incremental
2495      format.  *Note Incremental Dumps::.
2496
2497 `--lzma'
2498 `-J'
2499      This option tells `tar' to read or write archives through `lzma'.
2500      *Note gzip::.
2501
2502 `--lzop'
2503      This option tells `tar' to read or write archives through `lzop'.
2504      *Note gzip::.
2505
2506 `--mode=PERMISSIONS'
2507      When adding files to an archive, `tar' will use PERMISSIONS for
2508      the archive members, rather than the permissions from the files.
2509      PERMISSIONS can be specified either as an octal number or as
2510      symbolic permissions, like with `chmod'. *Note override::.
2511
2512 `--mtime=DATE'
2513      When adding files to an archive, `tar' will use DATE as the
2514      modification time of members when creating archives, instead of
2515      their actual modification times.  The value of DATE can be either
2516      a textual date representation (*note Date input formats::) or a
2517      name of the existing file, starting with `/' or `.'.  In the
2518      latter case, the modification time of that file is used. *Note
2519      override::.
2520
2521 `--multi-volume'
2522 `-M'
2523      Informs `tar' that it should create or otherwise operate on a
2524      multi-volume `tar' archive.  *Note Using Multiple Tapes::.
2525
2526 `--new-volume-script'
2527      (see -info-script)
2528
2529 `--newer=DATE'
2530 `--after-date=DATE'
2531 `-N'
2532      When creating an archive, `tar' will only add files that have
2533      changed since DATE.  If DATE begins with `/' or `.', it is taken
2534      to be the name of a file whose data modification time specifies
2535      the date.  *Note after::.
2536
2537 `--newer-mtime=DATE'
2538      Like `--newer', but add only files whose contents have changed (as
2539      opposed to just `--newer', which will also back up files for which
2540      any status information has changed).  *Note after::.
2541
2542 `--no-anchored'
2543      An exclude pattern can match any subsequence of the name's
2544      components.  *Note controlling pattern-matching::.
2545
2546 `--no-auto-compress'
2547      Disables automatic compressed format recognition based on the
2548      archive suffix.  *Note --auto-compress::.  *Note gzip::.
2549
2550 `--no-check-device'
2551      Do not check device numbers when creating a list of modified files
2552      for incremental archiving.  *Note device numbers::, for a detailed
2553      description.
2554
2555 `--no-delay-directory-restore'
2556      Modification times and permissions of extracted directories are
2557      set when all files from this directory have been extracted.  This
2558      is the default.  *Note Directory Modification Times and
2559      Permissions::.
2560
2561 `--no-ignore-case'
2562      Use case-sensitive matching.  *Note controlling pattern-matching::.
2563
2564 `--no-ignore-command-error'
2565      Print warnings about subprocesses that terminated with a nonzero
2566      exit code. *Note Writing to an External Program::.
2567
2568 `--no-null'
2569      If the `--null' option was given previously, this option cancels
2570      its effect, so that any following `--files-from' options will
2571      expect their file lists to be newline-terminated.
2572
2573 `--no-overwrite-dir'
2574      Preserve metadata of existing directories when extracting files
2575      from an archive.  *Note Overwrite Old Files::.
2576
2577 `--no-quote-chars=STRING'
2578      Remove characters listed in STRING from the list of quoted
2579      characters set by the previous `--quote-chars' option (*note
2580      quoting styles::).
2581
2582 `--no-recursion'
2583      With this option, `tar' will not recurse into directories.  *Note
2584      recurse::.
2585
2586 `--no-same-owner'
2587 `-o'
2588      When extracting an archive, do not attempt to preserve the owner
2589      specified in the `tar' archive.  This the default behavior for
2590      ordinary users.
2591
2592 `--no-same-permissions'
2593      When extracting an archive, subtract the user's umask from files
2594      from the permissions specified in the archive.  This is the
2595      default behavior for ordinary users.
2596
2597 `--no-unquote'
2598      Treat all input file or member names literally, do not interpret
2599      escape sequences.  *Note input name quoting::.
2600
2601 `--no-wildcards'
2602      Do not use wildcards.  *Note controlling pattern-matching::.
2603
2604 `--no-wildcards-match-slash'
2605      Wildcards do not match `/'.  *Note controlling pattern-matching::.
2606
2607 `--null'
2608      When `tar' is using the `--files-from' option, this option
2609      instructs `tar' to expect file names terminated with NUL, so `tar'
2610      can correctly work with file names that contain newlines.  *Note
2611      nul::.
2612
2613 `--numeric-owner'
2614      This option will notify `tar' that it should use numeric user and
2615      group IDs when creating a `tar' file, rather than names.  *Note
2616      Attributes::.
2617
2618 `-o'
2619      The function of this option depends on the action `tar' is
2620      performing.  When extracting files, `-o' is a synonym for
2621      `--no-same-owner', i.e., it prevents `tar' from restoring
2622      ownership of files being extracted.
2623
2624      When creating an archive, it is a synonym for `--old-archive'.
2625      This behavior is for compatibility with previous versions of GNU
2626      `tar', and will be removed in future releases.
2627
2628      *Note Changes::, for more information.
2629
2630 `--occurrence[=NUMBER]'
2631      This option can be used in conjunction with one of the subcommands
2632      `--delete', `--diff', `--extract' or `--list' when a list of files
2633      is given either on the command line or via `-T' option.
2634
2635      This option instructs `tar' to process only the NUMBERth
2636      occurrence of each named file.  NUMBER defaults to 1, so
2637
2638           tar -x -f archive.tar --occurrence filename
2639
2640      will extract the first occurrence of the member `filename' from
2641      `archive.tar' and will terminate without scanning to the end of
2642      the archive.
2643
2644 `--old-archive'
2645      Synonym for `--format=v7'.
2646
2647 `--one-file-system'
2648      Used when creating an archive.  Prevents `tar' from recursing into
2649      directories that are on different file systems from the current
2650      directory.
2651
2652 `--overwrite'
2653      Overwrite existing files and directory metadata when extracting
2654      files from an archive.  *Note Overwrite Old Files::.
2655
2656 `--overwrite-dir'
2657      Overwrite the metadata of existing directories when extracting
2658      files from an archive.  *Note Overwrite Old Files::.
2659
2660 `--owner=USER'
2661      Specifies that `tar' should use USER as the owner of members when
2662      creating archives, instead of the user associated with the source
2663      file.  USER is first decoded as a user symbolic name, but if this
2664      interpretation fails, it has to be a decimal numeric user ID.
2665      *Note override::.
2666
2667      This option does not affect extraction from archives.
2668
2669 `--pax-option=KEYWORD-LIST'
2670      This option is meaningful only with POSIX.1-2001 archives (*note
2671      posix::).  It modifies the way `tar' handles the extended header
2672      keywords.  KEYWORD-LIST is a comma-separated list of keyword
2673      options.  *Note PAX keywords::, for a detailed discussion.
2674
2675 `--portability'
2676 `--old-archive'
2677      Synonym for `--format=v7'.
2678
2679 `--posix'
2680      Same as `--format=posix'.
2681
2682 `--preserve'
2683      Synonymous with specifying both `--preserve-permissions' and
2684      `--same-order'.  *Note Setting Access Permissions::.
2685
2686 `--preserve-order'
2687      (See `--same-order'; *note Reading::.)
2688
2689 `--preserve-permissions'
2690 `--same-permissions'
2691 `-p'
2692      When `tar' is extracting an archive, it normally subtracts the
2693      users' umask from the permissions specified in the archive and uses
2694      that number as the permissions to create the destination file.
2695      Specifying this option instructs `tar' that it should use the
2696      permissions directly from the archive.  *Note Setting Access
2697      Permissions::.
2698
2699 `--quote-chars=STRING'
2700      Always quote characters from STRING, even if the selected quoting
2701      style would not quote them (*note quoting styles::).
2702
2703 `--quoting-style=STYLE'
2704      Set quoting style to use when printing member and file names
2705      (*note quoting styles::). Valid STYLE values are: `literal',
2706      `shell', `shell-always', `c', `escape', `locale', and `clocale'.
2707      Default quoting style is `escape', unless overridden while
2708      configuring the package.
2709
2710 `--read-full-records'
2711 `-B'
2712      Specifies that `tar' should reblock its input, for reading from
2713      pipes on systems with buggy implementations.  *Note Reading::.
2714
2715 `--record-size=SIZE'
2716      Instructs `tar' to use SIZE bytes per record when accessing the
2717      archive.  *Note Blocking Factor::.
2718
2719 `--recursion'
2720      With this option, `tar' recurses into directories (default).
2721      *Note recurse::.
2722
2723 `--recursive-unlink'
2724      Remove existing directory hierarchies before extracting
2725      directories of the same name from the archive.  *Note Recursive
2726      Unlink::.
2727
2728 `--remove-files'
2729      Directs `tar' to remove the source file from the file system after
2730      appending it to an archive.  *Note remove files::.
2731
2732 `--restrict'
2733      Disable use of some potentially harmful `tar' options.  Currently
2734      this option disables shell invocation from multi-volume menu
2735      (*note Using Multiple Tapes::).
2736
2737 `--rmt-command=CMD'
2738      Notifies `tar' that it should use CMD instead of the default
2739      `/usr/libexec/rmt' (*note Remote Tape Server::).
2740
2741 `--rsh-command=CMD'
2742      Notifies `tar' that is should use CMD to communicate with remote
2743      devices.  *Note Device::.
2744
2745 `--same-order'
2746 `--preserve-order'
2747 `-s'
2748      This option is an optimization for `tar' when running on machines
2749      with small amounts of memory.  It informs `tar' that the list of
2750      file arguments has already been sorted to match the order of files
2751      in the archive.  *Note Reading::.
2752
2753 `--same-owner'
2754      When extracting an archive, `tar' will attempt to preserve the
2755      owner specified in the `tar' archive with this option present.
2756      This is the default behavior for the superuser; this option has an
2757      effect only for ordinary users.  *Note Attributes::.
2758
2759 `--same-permissions'
2760      (See `--preserve-permissions'; *note Setting Access Permissions::.)
2761
2762 `--seek'
2763 `-n'
2764      Assume that the archive media supports seeks to arbitrary
2765      locations.  Usually `tar' determines automatically whether the
2766      archive can be seeked or not.  This option is intended for use in
2767      cases when such recognition fails.
2768
2769 `--show-defaults'
2770      Displays the default options used by `tar' and exits successfully.
2771      This option is intended for use in shell scripts.  Here is an
2772      example of what you can see using this option:
2773
2774           $ tar --show-defaults
2775           --format=gnu -f- -b20 --quoting-style=escape \
2776           --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
2777
2778 `--show-omitted-dirs'
2779      Instructs `tar' to mention the directories it is skipping when
2780      operating on a `tar' archive.  *Note show-omitted-dirs::.
2781
2782 `--show-transformed-names'
2783 `--show-stored-names'
2784      Display file or member names after applying any transformations
2785      (*note transform::).  In particular, when used in conjunction with
2786      one of the archive creation operations it instructs `tar' to list
2787      the member names stored in the archive, as opposed to the actual
2788      file names.  *Note listing member and file names::.
2789
2790 `--sparse'
2791 `-S'
2792      Invokes a GNU extension when adding files to an archive that
2793      handles sparse files efficiently.  *Note sparse::.
2794
2795 `--sparse-version=VERSION'
2796      Specifies the "format version" to use when archiving sparse files.
2797      Implies `--sparse'.  *Note sparse::. For the description of the
2798      supported sparse formats, *Note Sparse Formats::.
2799
2800 `--starting-file=NAME'
2801 `-K NAME'
2802      This option affects extraction only; `tar' will skip extracting
2803      files in the archive until it finds one that matches NAME.  *Note
2804      Scarce::.
2805
2806 `--strip-components=NUMBER'
2807      Strip given NUMBER of leading components from file names before
2808      extraction.  For example, if archive `archive.tar' contained
2809      `/some/file/name', then running
2810
2811           tar --extract --file archive.tar --strip-components=2
2812
2813      would extract this file to file `name'.
2814
2815      , summary
2816
2817 `--suffix=SUFFIX'
2818      Alters the suffix `tar' uses when backing up files from the default
2819      `~'.  *Note backup::.
2820
2821 `--tape-length=NUM'
2822 `-L NUM'
2823      Specifies the length of tapes that `tar' is writing as being
2824      NUM x 1024 bytes long.  *Note Using Multiple Tapes::.
2825
2826 `--test-label'
2827      Reads the volume label.  If an argument is specified, test whether
2828      it matches the volume label.  *Note --test-label option::.
2829
2830 `--to-command=COMMAND'
2831      During extraction `tar' will pipe extracted files to the standard
2832      input of COMMAND.  *Note Writing to an External Program::.
2833
2834 `--to-stdout'
2835 `-O'
2836      During extraction, `tar' will extract files to stdout rather than
2837      to the file system.  *Note Writing to Standard Output::.
2838
2839 `--totals[=SIGNO]'
2840      Displays the total number of bytes transferred when processing an
2841      archive.  If an argument is given, these data are displayed on
2842      request, when signal SIGNO is delivered to `tar'.  *Note totals::.
2843
2844 `--touch'
2845 `-m'
2846      Sets the data modification time of extracted files to the
2847      extraction time, rather than the data modification time stored in
2848      the archive.  *Note Data Modification Times::.
2849
2850 `--transform=SED-EXPR'
2851 `--xform=SED-EXPR'
2852      Transform file or member names using `sed' replacement expression
2853      SED-EXPR.  For example,
2854
2855           $ tar cf archive.tar --transform 's,^\./,usr/,' .
2856
2857      will add to `archive' files from the current working directory,
2858      replacing initial `./' prefix with `usr/'. For the detailed
2859      discussion, *Note transform::.
2860
2861      To see transformed member names in verbose listings, use
2862      `--show-transformed-names' option (*note show-transformed-names::).
2863
2864 `--uncompress'
2865      (See `--compress'. *note gzip::)
2866
2867 `--ungzip'
2868      (See `--gzip'. *note gzip::)
2869
2870 `--unlink-first'
2871 `-U'
2872      Directs `tar' to remove the corresponding file from the file
2873      system before extracting it from the archive.  *Note Unlink
2874      First::.
2875
2876 `--unquote'
2877      Enable unquoting input file or member names (default).  *Note
2878      input name quoting::.
2879
2880 `--use-compress-program=PROG'
2881      Instructs `tar' to access the archive through PROG, which is
2882      presumed to be a compression program of some sort.  *Note gzip::.
2883
2884 `--utc'
2885      Display file modification dates in UTC.  This option implies
2886      `--verbose'.
2887
2888 `--verbose'
2889 `-v'
2890      Specifies that `tar' should be more verbose about the operations
2891      it is performing.  This option can be specified multiple times for
2892      some operations to increase the amount of information displayed.
2893      *Note verbose::.
2894
2895 `--verify'
2896 `-W'
2897      Verifies that the archive was correctly written when creating an
2898      archive.  *Note verify::.
2899
2900 `--version'
2901      Print information about the program's name, version, origin and
2902      legal status, all on standard output, and then exit successfully.
2903      *Note help::.
2904
2905 `--volno-file=FILE'
2906      Used in conjunction with `--multi-volume'.  `tar' will keep track
2907      of which volume of a multi-volume archive it is working in FILE.
2908      *Note volno-file::.
2909
2910 `--wildcards'
2911      Use wildcards when matching member names with patterns.  *Note
2912      controlling pattern-matching::.
2913
2914 `--wildcards-match-slash'
2915      Wildcards match `/'.  *Note controlling pattern-matching::.
2916
2917    ---------- Footnotes ----------
2918
2919    (1) Earlier versions of GNU `tar' understood `-l' as a synonym for
2920 `--one-file-system'.  The current semantics, which complies to UNIX98,
2921 was introduced with version 1.15.91. *Note Changes::, for more
2922 information.
2923
2924 \1f
2925 File: tar.info,  Node: Short Option Summary,  Prev: Option Summary,  Up: All Options
2926
2927 3.4.3 Short Options Cross Reference
2928 -----------------------------------
2929
2930 Here is an alphabetized list of all of the short option forms, matching
2931 them with the equivalent long option.
2932
2933 Short Option   Reference
2934 -------------------------------------------------------------------------- 
2935 -A             *note --concatenate::.
2936 -B             *note --read-full-records::.
2937 -C             *note --directory::.
2938 -F             *note --info-script::.
2939 -G             *note --incremental::.
2940 -J             *note --lzma::.
2941 -K             *note --starting-file::.
2942 -L             *note --tape-length::.
2943 -M             *note --multi-volume::.
2944 -N             *note --newer::.
2945 -O             *note --to-stdout::.
2946 -P             *note --absolute-names::.
2947 -R             *note --block-number::.
2948 -S             *note --sparse::.
2949 -T             *note --files-from::.
2950 -U             *note --unlink-first::.
2951 -V             *note --label::.
2952 -W             *note --verify::.
2953 -X             *note --exclude-from::.
2954 -Z             *note --compress::.
2955 -b             *note --blocking-factor::.
2956 -c             *note --create::.
2957 -d             *note --compare::.
2958 -f             *note --file::.
2959 -g             *note --listed-incremental::.
2960 -h             *note --dereference::.
2961 -i             *note --ignore-zeros::.
2962 -j             *note --bzip2::.
2963 -k             *note --keep-old-files::.
2964 -l             *note --check-links::.
2965 -m             *note --touch::.
2966 -o             When creating, *note --no-same-owner::, when extracting --
2967                *note --portability::.
2968                
2969                   The latter usage is deprecated.  It is retained for
2970                compatibility with the earlier versions of GNU `tar'.  In
2971                future releases `-o' will be equivalent to
2972                `--no-same-owner' only.
2973 -p             *note --preserve-permissions::.
2974 -r             *note --append::.
2975 -s             *note --same-order::.
2976 -t             *note --list::.
2977 -u             *note --update::.
2978 -v             *note --verbose::.
2979 -w             *note --interactive::.
2980 -x             *note --extract::.
2981 -z             *note --gzip::.
2982
2983 \1f
2984 File: tar.info,  Node: help,  Next: defaults,  Prev: All Options,  Up: tar invocation
2985
2986 3.5 GNU `tar' documentation
2987 ===========================
2988
2989 Being careful, the first thing is really checking that you are using
2990 GNU `tar', indeed.  The `--version' option causes `tar' to print
2991 information about its name, version, origin and legal status, all on
2992 standard output, and then exit successfully.  For example,
2993 `tar --version' might print:
2994
2995      tar (GNU tar) 1.21
2996      Copyright (C) 2008 Free Software Foundation, Inc.
2997      This is free software.  You may redistribute copies of it under the terms
2998      of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
2999      There is NO WARRANTY, to the extent permitted by law.
3000
3001      Written by John Gilmore and Jay Fenlason.
3002
3003 The first occurrence of `tar' in the result above is the program name
3004 in the package (for example, `rmt' is another program), while the
3005 second occurrence of `tar' is the name of the package itself,
3006 containing possibly many programs.  The package is currently named
3007 `tar', after the name of the main program it contains(1).
3008
3009    Another thing you might want to do is checking the spelling or
3010 meaning of some particular `tar' option, without resorting to this
3011 manual, for once you have carefully read it.  GNU `tar' has a short
3012 help feature, triggerable through the `--help' option.  By using this
3013 option, `tar' will print a usage message listing all available options
3014 on standard output, then exit successfully, without doing anything else
3015 and ignoring all other options.  Even if this is only a brief summary,
3016 it may be several screens long.  So, if you are not using some kind of
3017 scrollable window, you might prefer to use something like:
3018
3019      $ tar --help | less
3020
3021 presuming, here, that you like using `less' for a pager.  Other popular
3022 pagers are `more' and `pg'.  If you know about some KEYWORD which
3023 interests you and do not want to read all the `--help' output, another
3024 common idiom is doing:
3025
3026      tar --help | grep KEYWORD
3027
3028 for getting only the pertinent lines.  Notice, however, that some `tar'
3029 options have long description lines and the above command will list
3030 only the first of them.
3031
3032    The exact look of the option summary displayed by `tar --help' is
3033 configurable. *Note Configuring Help Summary::, for a detailed
3034 description.
3035
3036    If you only wish to check the spelling of an option, running `tar
3037 --usage' may be a better choice.  This will display a terse list of
3038 `tar' option without accompanying explanations.
3039
3040    The short help output is quite succinct, and you might have to get
3041 back to the full documentation for precise points.  If you are reading
3042 this paragraph, you already have the `tar' manual in some form.  This
3043 manual is available in a variety of forms from
3044 `http://www.gnu.org/software/tar/manual'.  It may be printed out of the
3045 GNU `tar' distribution, provided you have TeX already installed
3046 somewhere, and a laser printer around.  Just configure the
3047 distribution, execute the command `make dvi', then print `doc/tar.dvi'
3048 the usual way (contact your local guru to know how).  If GNU `tar' has
3049 been conveniently installed at your place, this manual is also
3050 available in interactive, hypertextual form as an Info file.  Just call
3051 `info tar' or, if you do not have the `info' program handy, use the
3052 Info reader provided within GNU Emacs, calling `tar' from the main Info
3053 menu.
3054
3055    There is currently no `man' page for GNU `tar'.  If you observe such
3056 a `man' page on the system you are running, either it does not belong
3057 to GNU `tar', or it has not been produced by GNU.  Some package
3058 maintainers convert `tar --help' output to a man page, using
3059 `help2man'.  In any case, please bear in mind that the authoritative
3060 source of information about GNU `tar' is this Texinfo documentation.
3061
3062    ---------- Footnotes ----------
3063
3064    (1) There are plans to merge the `cpio' and `tar' packages into a
3065 single one which would be called `paxutils'.  So, who knows if, one of
3066 this days, the `--version' would not output `tar (GNU paxutils) 3.2'
3067
3068 \1f
3069 File: tar.info,  Node: defaults,  Next: verbose,  Prev: help,  Up: tar invocation
3070
3071 3.6 Obtaining GNU `tar' default values
3072 ======================================
3073
3074 GNU `tar' has some predefined defaults that are used when you do not
3075 explicitly specify another values.  To obtain a list of such defaults,
3076 use `--show-defaults' option.  This will output the values in the form
3077 of `tar' command line options:
3078
3079      tar --show-defaults
3080      --format=gnu -f- -b20 --quoting-style=escape
3081      --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
3082
3083 Notice, that this option outputs only one line.  The example output
3084 above has been split to fit page boundaries.
3085
3086 The above output shows that this version of GNU `tar' defaults to using
3087 `gnu' archive format (*note Formats::), it uses standard output as the
3088 archive, if no `--file' option has been given (*note file tutorial::),
3089 the default blocking factor is 20 (*note Blocking Factor::).  It also
3090 shows the default locations where `tar' will look for `rmt' and `rsh'
3091 binaries.
3092
3093 \1f
3094 File: tar.info,  Node: verbose,  Next: checkpoints,  Prev: defaults,  Up: tar invocation
3095
3096 3.7 Checking `tar' progress
3097 ===========================
3098
3099 Typically, `tar' performs most operations without reporting any
3100 information to the user except error messages.  When using `tar' with
3101 many options, particularly ones with complicated or
3102 difficult-to-predict behavior, it is possible to make serious mistakes.
3103 `tar' provides several options that make observing `tar' easier.  These
3104 options cause `tar' to print information as it progresses in its job,
3105 and you might want to use them just for being more careful about what
3106 is going on, or merely for entertaining yourself.  If you have
3107 encountered a problem when operating on an archive, however, you may
3108 need more information than just an error message in order to solve the
3109 problem.  The following options can be helpful diagnostic tools.
3110
3111    Normally, the `--list' (`-t') command to list an archive prints just
3112 the file names (one per line) and the other commands are silent. When
3113 used with most operations, the `--verbose' (`-v') option causes `tar'
3114 to print the name of each file or archive member as it is processed.
3115 This and the other options which make `tar' print status information
3116 can be useful in monitoring `tar'.
3117
3118    With `--create' or `--extract', `--verbose' used once just prints
3119 the names of the files or members as they are processed.  Using it
3120 twice causes `tar' to print a longer listing (*Note verbose member
3121 listing::, for the description) for each member.  Since `--list'
3122 already prints  the names of the members, `--verbose' used once with
3123 `--list' causes `tar' to print an `ls -l' type listing of the files in
3124 the archive.  The following examples both extract members with long
3125 list output:
3126
3127      $ tar --extract --file=archive.tar --verbose --verbose
3128      $ tar xvvf archive.tar
3129
3130    Verbose output appears on the standard output except when an archive
3131 is being written to the standard output, as with `tar --create --file=-
3132 --verbose' (`tar cfv -', or even `tar cv'--if the installer let
3133 standard output be the default archive).  In that case `tar' writes
3134 verbose output to the standard error stream.
3135
3136    If `--index-file=FILE' is specified, `tar' sends verbose output to
3137 FILE rather than to standard output or standard error.
3138
3139    The `--totals' option causes `tar' to print on the standard error
3140 the total amount of bytes transferred when processing an archive.  When
3141 creating or appending to an archive, this option prints the number of
3142 bytes written to the archive and the average speed at which they have
3143 been written, e.g.:
3144
3145      $ tar -c -f archive.tar --totals /home
3146      Total bytes written: 7924664320 (7.4GiB, 85MiB/s)
3147
3148    When reading an archive, this option displays the number of bytes
3149 read:
3150
3151      $ tar -x -f archive.tar --totals
3152      Total bytes read: 7924664320 (7.4GiB, 95MiB/s)
3153
3154    Finally, when deleting from an archive, the `--totals' option
3155 displays both numbers plus number of bytes removed from the archive:
3156
3157      $ tar --delete -f foo.tar --totals --wildcards '*~'
3158      Total bytes read: 9543680 (9.2MiB, 201MiB/s)
3159      Total bytes written: 3829760 (3.7MiB, 81MiB/s)
3160      Total bytes deleted: 1474048
3161
3162    You can also obtain this information on request.  When `--totals' is
3163 used with an argument, this argument is interpreted as a symbolic name
3164 of a signal, upon delivery of which the statistics is to be printed:
3165
3166 `--totals=SIGNO'
3167      Print statistics upon delivery of signal SIGNO.  Valid arguments
3168      are: `SIGHUP', `SIGQUIT', `SIGINT', `SIGUSR1' and `SIGUSR2'.
3169      Shortened names without `SIG' prefix are also accepted.
3170
3171    Both forms of `--totals' option can be used simultaneously.  Thus,
3172 `tar -x --totals --totals=USR1' instructs `tar' to extract all members
3173 from its default archive and print statistics after finishing the
3174 extraction, as well as when receiving signal `SIGUSR1'.
3175
3176    The `--checkpoint' option prints an occasional message as `tar'
3177 reads or writes the archive.  It is designed for those who don't need
3178 the more detailed (and voluminous) output of `--block-number' (`-R'),
3179 but do want visual confirmation that `tar' is actually making forward
3180 progress.  By default it prints a message each 10 records read or
3181 written.  This can be changed by giving it a numeric argument after an
3182 equal sign:
3183
3184      $ tar -c --checkpoint=1000 /var
3185      tar: Write checkpoint 1000
3186      tar: Write checkpoint 2000
3187      tar: Write checkpoint 3000
3188
3189    This example shows the default checkpoint message used by `tar'.  If
3190 you place a dot immediately after the equal sign, it will print a `.'
3191 at each checkpoint(1).  For example:
3192
3193      $ tar -c --checkpoint=.1000 /var
3194      ...
3195
3196    The `--checkpoint' option provides a flexible mechanism for
3197 executing arbitrary actions upon hitting checkpoints, see the next
3198 section (*note checkpoints::), for more information on it.
3199
3200    The `--show-omitted-dirs' option, when reading an archive--with
3201 `--list' or `--extract', for example--causes a message to be printed
3202 for each directory in the archive which is skipped.  This happens
3203 regardless of the reason for skipping: the directory might not have
3204 been named on the command line (implicitly or explicitly), it might be
3205 excluded by the use of the `--exclude=PATTERN' option, or some other
3206 reason.
3207
3208    If `--block-number' (`-R') is used, `tar' prints, along with every
3209 message it would normally produce, the block number within the archive
3210 where the message was triggered.  Also, supplementary messages are
3211 triggered when reading blocks full of NULs, or when hitting end of file
3212 on the archive.  As of now, if the archive if properly terminated with
3213 a NUL block, the reading of the file may stop before end of file is
3214 met, so the position of end of file will not usually show when
3215 `--block-number' (`-R') is used.  Note that GNU `tar' drains the
3216 archive before exiting when reading the archive from a pipe.
3217
3218    This option is especially useful when reading damaged archives, since
3219 it helps pinpoint the damaged sections.  It can also be used with
3220 `--list' (`-t') when listing a file-system backup tape, allowing you to
3221 choose among several backup tapes when retrieving a file later, in
3222 favor of the tape where the file appears earliest (closest to the front
3223 of the tape).  *Note backup::.
3224
3225    ---------- Footnotes ----------
3226
3227    (1) This is actually a shortcut for `--checkpoint=N
3228 --checkpoint-action=dot'.  *Note dot: checkpoints.
3229
3230 \1f
3231 File: tar.info,  Node: checkpoints,  Next: interactive,  Prev: verbose,  Up: tar invocation
3232
3233 3.8 Checkpoints
3234 ===============
3235
3236 A "checkpoint" is a moment of time before writing Nth record to the
3237 archive (a "write checkpoint"), or before reading Nth record from the
3238 archive (a "read checkpoint").  Checkpoints allow to periodically
3239 execute arbitrary actions.
3240
3241    The checkpoint facility is enabled using the following option:
3242
3243 `--checkpoint[=N]'
3244      Schedule checkpoints before writing or reading each Nth record.
3245      The default value for N is 10.
3246
3247    A list of arbitrary "actions" can be executed at each checkpoint.
3248 These actions include: pausing, displaying textual messages, and
3249 executing arbitrary external programs.  Actions are defined using the
3250 `--checkpoint-action' option.
3251
3252 `--checkpoint-action=ACTION'
3253      Execute an ACTION at each checkpoint.
3254
3255    The simplest value of ACTION is `echo'.  It instructs `tar' to
3256 display the default message on the standard error stream upon arriving
3257 at each checkpoint.  The default message is (in POSIX locale) `Write
3258 checkpoint N', for write checkpoints, and `Read checkpoint N', for read
3259 checkpoints.  Here, N represents ordinal number of the checkpoint.
3260
3261    In another locales, translated versions of this message are used.
3262
3263    This is the default action, so running:
3264
3265      $ tar -c --checkpoint=1000 --checkpoint-action=echo /var
3266
3267 is equivalent to:
3268
3269      $ tar -c --checkpoint=1000 /var
3270
3271    The `echo' action also allows to supply a customized message.  You
3272 do so by placing an equals sign and the message right after it, e.g.:
3273
3274      --checkpoint-action="echo=Hit %s checkpoint #%u"
3275
3276    The `%s' and `%u' in the above example are "meta-characters".  The
3277 `%s' meta-character is replaced with the "type" of the checkpoint:
3278 `write' or `read' (or a corresponding translated version in locales
3279 other than POSIX).  The `%u' meta-character is replaced with the
3280 ordinal number of the checkpoint.  Thus, the above example could
3281 produce the following output when used with the `--create' option:
3282
3283      tar: Hit write checkpoint #10
3284      tar: Hit write checkpoint #20
3285      tar: Hit write checkpoint #30
3286
3287    Aside from meta-character expansion, the message string is subject to
3288 "unquoting", during which the backslash "escape sequences" are replaced
3289 with their corresponding ASCII characters (*note escape sequences::).
3290 E.g. the following action will produce an audible bell and the message
3291 described above at each checkpoint:
3292
3293      --checkpoint-action='echo=\aHit %s checkpoint #%u'
3294
3295    There is also a special action which produces an audible signal:
3296 `bell'.  It is not equivalent to `echo='\a'', because `bell' sends the
3297 bell directly to the console (`/dev/tty'), whereas `echo='\a'' sends it
3298 to the standard error.
3299
3300    The `ttyout=STRING' action outputs STRING to `/dev/tty', so it can
3301 be used even if the standard output is redirected elsewhere.  The
3302 STRING is subject to the same modifications as with `echo' action.  In
3303 contrast to the latter, `ttyout' does not prepend `tar' executable name
3304 to the string, nor does it output a newline after it.  For example, the
3305 following action will print the checkpoint message at the same screen
3306 line, overwriting any previous message:
3307
3308      --checkpoint-action="ttyout=\rHit %s checkpoint #%u"
3309
3310    Another available checkpoint action is `dot' (or `.').  It instructs
3311 `tar' to print a single dot on the standard listing stream, e.g.:
3312
3313      $ tar -c --checkpoint=1000 --checkpoint-action=dot /var
3314      ...
3315
3316    For compatibility with previous GNU `tar' versions, this action can
3317 be abbreviated by placing a dot in front of the checkpoint frequency,
3318 as shown in the previous section.
3319
3320    Yet another action, `sleep', pauses `tar' for a specified amount of
3321 seconds.  The following example will stop for 30 seconds at each
3322 checkpoint:
3323
3324      $ tar -c --checkpoint=1000 --checkpoint-action=sleep=30
3325
3326    Finally, the `exec' action executes a given external program.  For
3327 example:
3328
3329      $ tar -c --checkpoint=1000 --checkpoint-action=exec=/sbin/cpoint
3330
3331    This program is executed using `/bin/sh -c', with no additional
3332 arguments.  Its exit code is ignored.  It gets a copy of `tar''s
3333 environment plus the following variables:
3334
3335 `TAR_VERSION'
3336      GNU `tar' version number.
3337
3338 `TAR_ARCHIVE'
3339      The name of the archive `tar' is processing.
3340
3341 `TAR_BLOCKING_FACTOR'
3342      Current blocking factor (*note Blocking::).
3343
3344 `TAR_CHECKPOINT'
3345      Number of the checkpoint.
3346
3347 `TAR_SUBCOMMAND'
3348      A short option describing the operation `tar' is executing.  *Note
3349      Operations::, for a complete list of subcommand options.
3350
3351 `TAR_FORMAT'
3352      Format of the archive being processed. *Note Formats::, for a
3353      complete list of archive format names.
3354
3355    Any number of actions can be defined, by supplying several
3356 `--checkpoint-action' options in the command line.  For example, the
3357 command below displays two messages, pauses execution for 30 seconds
3358 and executes the `/sbin/cpoint' script:
3359
3360      $ tar -c -f arc.tar \
3361             --checkpoint-action='\aecho=Hit %s checkpoint #%u' \
3362             --checkpoint-action='echo=Sleeping for 30 seconds' \
3363             --checkpoint-action='sleep=30' \
3364             --checkpoint-action='exec=/sbin/cpoint'
3365
3366    This example also illustrates the fact that `--checkpoint-action'
3367 can be used without `--checkpoint'.  In this case, the default
3368 checkpoint frequency (at each 10th record) is assumed.
3369
3370 \1f
3371 File: tar.info,  Node: interactive,  Prev: checkpoints,  Up: tar invocation
3372
3373 3.9 Asking for Confirmation During Operations
3374 =============================================
3375
3376 Typically, `tar' carries out a command without stopping for further
3377 instructions.  In some situations however, you may want to exclude some
3378 files and archive members from the operation (for instance if disk or
3379 storage space is tight).  You can do this by excluding certain files
3380 automatically (*note Choosing::), or by performing an operation
3381 interactively, using the `--interactive' (`-w') option.  `tar' also
3382 accepts `--confirmation' for this option.
3383
3384    When the `--interactive' (`-w') option is specified, before reading,
3385 writing, or deleting files, `tar' first prints a message for each such
3386 file, telling what operation it intends to take, then asks for
3387 confirmation on the terminal.  The actions which require confirmation
3388 include adding a file to the archive, extracting a file from the
3389 archive, deleting a file from the archive, and deleting a file from
3390 disk.  To confirm the action, you must type a line of input beginning
3391 with `y'.  If your input line begins with anything other than `y',
3392 `tar' skips that file.
3393
3394    If `tar' is reading the archive from the standard input, `tar' opens
3395 the file `/dev/tty' to support the interactive communications.
3396
3397    Verbose output is normally sent to standard output, separate from
3398 other error messages.  However, if the archive is produced directly on
3399 standard output, then verbose output is mixed with errors on `stderr'.
3400 Producing the archive on standard output may be used as a way to avoid
3401 using disk space, when the archive is soon to be consumed by another
3402 process reading it, say.  Some people felt the need of producing an
3403 archive on stdout, still willing to segregate between verbose output
3404 and error output.  A possible approach would be using a named pipe to
3405 receive the archive, and having the consumer process to read from that
3406 named pipe.  This has the advantage of letting standard output free to
3407 receive verbose output, all separate from errors.
3408
3409 \1f
3410 File: tar.info,  Node: operations,  Next: Backups,  Prev: tar invocation,  Up: Top
3411
3412 4 GNU `tar' Operations
3413 **********************
3414
3415 * Menu:
3416
3417 * Basic tar::
3418 * Advanced tar::
3419 * create options::
3420 * extract options::
3421 * backup::
3422 * Applications::
3423 * looking ahead::
3424
3425 \1f
3426 File: tar.info,  Node: Basic tar,  Next: Advanced tar,  Up: operations
3427
3428 4.1 Basic GNU `tar' Operations
3429 ==============================
3430
3431 The basic `tar' operations, `--create' (`-c'), `--list' (`-t') and
3432 `--extract' (`--get', `-x'), are currently presented and described in
3433 the tutorial chapter of this manual.  This section provides some
3434 complementary notes for these operations.
3435
3436 `--create'
3437 `-c'
3438      Creating an empty archive would have some kind of elegance.  One
3439      can initialize an empty archive and later use `--append' (`-r')
3440      for adding all members.  Some applications would not welcome
3441      making an exception in the way of adding the first archive member.
3442      On the other hand, many people reported that it is dangerously too
3443      easy for `tar' to destroy a magnetic tape with an empty
3444      archive(1).  The two most common errors are:
3445
3446        1. Mistakingly using `create' instead of `extract', when the
3447           intent was to extract the full contents of an archive.  This
3448           error is likely: keys `c' and `x' are right next to each
3449           other on the QWERTY keyboard.  Instead of being unpacked, the
3450           archive then gets wholly destroyed.  When users speak about
3451           "exploding" an archive, they usually mean something else :-).
3452
3453        2. Forgetting the argument to `file', when the intent was to
3454           create an archive with a single file in it.  This error is
3455           likely because a tired user can easily add the `f' key to the
3456           cluster of option letters, by the mere force of habit,
3457           without realizing the full consequence of doing so.  The
3458           usual consequence is that the single file, which was meant to
3459           be saved, is rather destroyed.
3460
3461      So, recognizing the likelihood and the catastrophic nature of these
3462      errors, GNU `tar' now takes some distance from elegance, and
3463      cowardly refuses to create an archive when `--create' option is
3464      given, there are no arguments besides options, and `--files-from'
3465      (`-T') option is _not_ used.  To get around the cautiousness of
3466      GNU `tar' and nevertheless create an archive with nothing in it,
3467      one may still use, as the value for the `--files-from' option, a
3468      file with no names in it, as shown in the following commands:
3469
3470           tar --create --file=empty-archive.tar --files-from=/dev/null
3471           tar cfT empty-archive.tar /dev/null
3472
3473 `--extract'
3474 `--get'
3475 `-x'
3476      A socket is stored, within a GNU `tar' archive, as a pipe.
3477
3478 ``--list' (`-t')'
3479      GNU `tar' now shows dates as `1996-08-30', while it used to show
3480      them as `Aug 30 1996'. Preferably, people should get used to ISO
3481      8601 dates.  Local American dates should be made available again
3482      with full date localization support, once ready.  In the meantime,
3483      programs not being localizable for dates should prefer
3484      international dates, that's really the way to go.
3485
3486      Look up `http://www.cl.cam.ac.uk/~mgk25/iso-time.html' if you are
3487      curious, it contains a detailed explanation of the ISO 8601
3488      standard.
3489
3490
3491    ---------- Footnotes ----------
3492
3493    (1) This is well described in `Unix-haters Handbook', by Simson
3494 Garfinkel, Daniel Weise & Steven Strassmann, IDG Books, ISBN
3495 1-56884-203-1.
3496
3497 \1f
3498 File: tar.info,  Node: Advanced tar,  Next: create options,  Prev: Basic tar,  Up: operations
3499
3500 4.2 Advanced GNU `tar' Operations
3501 =================================
3502
3503 Now that you have learned the basics of using GNU `tar', you may want
3504 to learn about further ways in which `tar' can help you.
3505
3506    This chapter presents five, more advanced operations which you
3507 probably won't use on a daily basis, but which serve more specialized
3508 functions.  We also explain the different styles of options and why you
3509 might want to use one or another, or a combination of them in your `tar'
3510 commands.  Additionally, this chapter includes options which allow you
3511 to define the output from `tar' more carefully, and provide help and
3512 error correction in special circumstances.
3513
3514 * Menu:
3515
3516 * Operations::
3517 * append::
3518 * update::
3519 * concatenate::
3520 * delete::
3521 * compare::
3522
3523 \1f
3524 File: tar.info,  Node: Operations,  Next: append,  Up: Advanced tar
3525
3526 4.2.1 The Five Advanced `tar' Operations
3527 ----------------------------------------
3528
3529      _(This message will disappear, once this node revised.)_
3530
3531 In the last chapter, you learned about the first three operations to
3532 `tar'.  This chapter presents the remaining five operations to `tar':
3533 `--append', `--update', `--concatenate', `--delete', and `--compare'.
3534
3535    You are not likely to use these operations as frequently as those
3536 covered in the last chapter; however, since they perform specialized
3537 functions, they are quite useful when you do need to use them.  We will
3538 give examples using the same directory and files that you created in
3539 the last chapter.  As you may recall, the directory is called
3540 `practice', the files are `jazz', `blues', `folk', `rock', and the two
3541 archive files you created are `collection.tar' and `music.tar'.
3542
3543    We will also use the archive files `afiles.tar' and `bfiles.tar'.
3544 The archive `afiles.tar' contains the members `apple', `angst', and
3545 `aspic'; `bfiles.tar' contains the members `./birds', `baboon', and
3546 `./box'.
3547
3548    Unless we state otherwise, all practicing you do and examples you
3549 follow in this chapter will take place in the `practice' directory that
3550 you created in the previous chapter; see *note prepare for examples::.
3551 (Below in this section, we will remind you of the state of the examples
3552 where the last chapter left them.)
3553
3554    The five operations that we will cover in this chapter are:
3555
3556 `--append'
3557 `-r'
3558      Add new entries to an archive that already exists.
3559
3560 `--update'
3561 `-r'
3562      Add more recent copies of archive members to the end of an
3563      archive, if they exist.
3564
3565 `--concatenate'
3566 `--catenate'
3567 `-A'
3568      Add one or more pre-existing archives to the end of another
3569      archive.
3570
3571 `--delete'
3572      Delete items from an archive (does not work on tapes).
3573
3574 `--compare'
3575 `--diff'
3576 `-d'
3577      Compare archive members to their counterparts in the file system.
3578
3579 \1f
3580 File: tar.info,  Node: append,  Next: update,  Prev: Operations,  Up: Advanced tar
3581
3582 4.2.2 How to Add Files to Existing Archives: `--append'
3583 -------------------------------------------------------
3584
3585      _(This message will disappear, once this node revised.)_
3586
3587 If you want to add files to an existing archive, you don't need to
3588 create a new archive; you can use `--append' (`-r').  The archive must
3589 already exist in order to use `--append'.  (A related operation is the
3590 `--update' operation; you can use this to add newer versions of archive
3591 members to an existing archive.  To learn how to do this with
3592 `--update', *note update::.)
3593
3594    If you use `--append' to add a file that has the same name as an
3595 archive member to an archive containing that archive member, then the
3596 old member is not deleted.  What does happen, however, is somewhat
3597 complex.  `tar' _allows_ you to have infinite number of files with the
3598 same name.  Some operations treat these same-named members no
3599 differently than any other set of archive members: for example, if you
3600 view an archive with `--list' (`-t'), you will see all of those members
3601 listed, with their data modification times, owners, etc.
3602
3603    Other operations don't deal with these members as perfectly as you
3604 might prefer; if you were to use `--extract' to extract the archive,
3605 only the most recently added copy of a member with the same name as four
3606 other members would end up in the working directory.  This is because
3607 `--extract' extracts an archive in the order the members appeared in
3608 the archive; the most recently archived members will be extracted last.
3609 Additionally, an extracted member will _replace_ a file of the same
3610 name which existed in the directory already, and `tar' will not prompt
3611 you about this(1).  Thus, only the most recently archived member will
3612 end up being extracted, as it will replace the one extracted before it,
3613 and so on.
3614
3615    There exists a special option that allows you to get around this
3616 behavior and extract (or list) only a particular copy of the file.
3617 This is `--occurrence' option.  If you run `tar' with this option, it
3618 will extract only the first copy of the file.  You may also give this
3619 option an argument specifying the number of copy to be extracted.
3620 Thus, for example if the archive `archive.tar' contained three copies
3621 of file `myfile', then the command
3622
3623      tar --extract --file archive.tar --occurrence=2 myfile
3624
3625 would extract only the second copy.  *Note --occurrence: Option
3626 Summary, for the description of `--occurrence' option.
3627
3628    If you want to replace an archive member, use `--delete' to delete
3629 the member you want to remove from the archive, , and then use
3630 `--append' to add the member you want to be in the archive.  Note that
3631 you can not change the order of the archive; the most recently added
3632 member will still appear last.  In this sense, you cannot truly
3633 "replace" one member with another.  (Replacing one member with another
3634 will not work on certain types of media, such as tapes; see *note
3635 delete:: and *note Media::, for more information.)
3636
3637 * Menu:
3638
3639 * appending files::             Appending Files to an Archive
3640 * multiple::
3641
3642    ---------- Footnotes ----------
3643
3644    (1) Unless you give it `--keep-old-files' option, or the disk copy
3645 is newer than the the one in the archive and you invoke `tar' with
3646 `--keep-newer-files' option
3647
3648 \1f
3649 File: tar.info,  Node: appending files,  Next: multiple,  Up: append
3650
3651 4.2.2.1 Appending Files to an Archive
3652 .....................................
3653
3654      _(This message will disappear, once this node revised.)_
3655
3656 The simplest way to add a file to an already existing archive is the
3657 `--append' (`-r') operation, which writes specified files into the
3658 archive whether or not they are already among the archived files.
3659
3660    When you use `--append', you _must_ specify file name arguments, as
3661 there is no default.  If you specify a file that already exists in the
3662 archive, another copy of the file will be added to the end of the
3663 archive.  As with other operations, the member names of the newly added
3664 files will be exactly the same as their names given on the command
3665 line.  The `--verbose' (`-v') option will print out the names of the
3666 files as they are written into the archive.
3667
3668    `--append' cannot be performed on some tape drives, unfortunately,
3669 due to deficiencies in the formats those tape drives use.  The archive
3670 must be a valid `tar' archive, or else the results of using this
3671 operation will be unpredictable.  *Note Media::.
3672
3673    To demonstrate using `--append' to add a file to an archive, create
3674 a file called `rock' in the `practice' directory.  Make sure you are in
3675 the `practice' directory.  Then, run the following `tar' command to add
3676 `rock' to `collection.tar':
3677
3678      $ tar --append --file=collection.tar rock
3679
3680 If you now use the `--list' (`-t') operation, you will see that `rock'
3681 has been added to the archive:
3682
3683      $ tar --list --file=collection.tar
3684      -rw-r--r-- me user     28 1996-10-18 16:31 jazz
3685      -rw-r--r-- me user     21 1996-09-23 16:44 blues
3686      -rw-r--r-- me user     20 1996-09-23 16:44 folk
3687      -rw-r--r-- me user     20 1996-09-23 16:44 rock
3688
3689 \1f
3690 File: tar.info,  Node: multiple,  Prev: appending files,  Up: append
3691
3692 4.2.2.2 Multiple Members with the Same Name
3693 ...........................................
3694
3695 You can use `--append' (`-r') to add copies of files which have been
3696 updated since the archive was created.  (However, we do not recommend
3697 doing this since there is another `tar' option called `--update'; *Note
3698 update::, for more information.  We describe this use of `--append'
3699 here for the sake of completeness.)  When you extract the archive, the
3700 older version will be effectively lost.  This works because files are
3701 extracted from an archive in the order in which they were archived.
3702 Thus, when the archive is extracted, a file archived later in time will
3703 replace a file of the same name which was archived earlier, even though
3704 the older version of the file will remain in the archive unless you
3705 delete all versions of the file.
3706
3707    Supposing you change the file `blues' and then append the changed
3708 version to `collection.tar'.  As you saw above, the original `blues' is
3709 in the archive `collection.tar'.  If you change the file and append the
3710 new version of the file to the archive, there will be two copies in the
3711 archive.  When you extract the archive, the older version of the file
3712 will be extracted first, and then replaced by the newer version when it
3713 is extracted.
3714
3715    You can append the new, changed copy of the file `blues' to the
3716 archive in this way:
3717
3718      $ tar --append --verbose --file=collection.tar blues
3719      blues
3720
3721 Because you specified the `--verbose' option, `tar' has printed the
3722 name of the file being appended as it was acted on.  Now list the
3723 contents of the archive:
3724
3725      $ tar --list --verbose --file=collection.tar
3726      -rw-r--r-- me user     28 1996-10-18 16:31 jazz
3727      -rw-r--r-- me user     21 1996-09-23 16:44 blues
3728      -rw-r--r-- me user     20 1996-09-23 16:44 folk
3729      -rw-r--r-- me user     20 1996-09-23 16:44 rock
3730      -rw-r--r-- me user     58 1996-10-24 18:30 blues
3731
3732 The newest version of `blues' is now at the end of the archive (note
3733 the different creation dates and file sizes).  If you extract the
3734 archive, the older version of the file `blues' will be replaced by the
3735 newer version.  You can confirm this by extracting the archive and
3736 running `ls' on the directory.
3737
3738    If you wish to extract the first occurrence of the file `blues' from
3739 the archive, use `--occurrence' option, as shown in the following
3740 example:
3741
3742      $ tar --extract -vv --occurrence --file=collection.tar blues
3743      -rw-r--r-- me user     21 1996-09-23 16:44 blues
3744
3745    *Note Writing::, for more information on `--extract' and *Note
3746 -occurrence: Option Summary, for the description of `--occurrence'
3747 option.
3748
3749 \1f
3750 File: tar.info,  Node: update,  Next: concatenate,  Prev: append,  Up: Advanced tar
3751
3752 4.2.3 Updating an Archive
3753 -------------------------
3754
3755      _(This message will disappear, once this node revised.)_
3756
3757 In the previous section, you learned how to use `--append' to add a
3758 file to an existing archive.  A related operation is `--update' (`-u').
3759 The `--update' operation updates a `tar' archive by comparing the date
3760 of the specified archive members against the date of the file with the
3761 same name.  If the file has been modified more recently than the
3762 archive member, then the newer version of the file is added to the
3763 archive (as with `--append').
3764
3765    Unfortunately, you cannot use `--update' with magnetic tape drives.
3766 The operation will fail.
3767
3768    Both `--update' and `--append' work by adding to the end of the
3769 archive.  When you extract a file from the archive, only the version
3770 stored last will wind up in the file system, unless you use the
3771 `--backup' option.  *Note multiple::, for a detailed discussion.
3772
3773 * Menu:
3774
3775 * how to update::
3776
3777 \1f
3778 File: tar.info,  Node: how to update,  Up: update
3779
3780 4.2.3.1 How to Update an Archive Using `--update'
3781 .................................................
3782
3783 You must use file name arguments with the `--update' (`-u') operation.
3784 If you don't specify any files, `tar' won't act on any files and won't
3785 tell you that it didn't do anything (which may end up confusing you).
3786
3787    To see the `--update' option at work, create a new file,
3788 `classical', in your practice directory, and some extra text to the
3789 file `blues', using any text editor.  Then invoke `tar' with the
3790 `update' operation and the `--verbose' (`-v') option specified, using
3791 the names of all the files in the practice directory as file name
3792 arguments:
3793
3794      $ tar --update -v -f collection.tar blues folk rock classical
3795      blues
3796      classical
3797      $
3798
3799 Because we have specified verbose mode, `tar' prints out the names of
3800 the files it is working on, which in this case are the names of the
3801 files that needed to be updated.  If you run `tar --list' and look at
3802 the archive, you will see `blues' and `classical' at its end.  There
3803 will be a total of two versions of the member `blues'; the one at the
3804 end will be newer and larger, since you added text before updating it.
3805
3806    (The reason `tar' does not overwrite the older file when updating it
3807 is because writing to the middle of a section of tape is a difficult
3808 process.  Tapes are not designed to go backward.  *Note Media::, for
3809 more information about tapes.
3810
3811    `--update' (`-u') is not suitable for performing backups for two
3812 reasons: it does not change directory content entries, and it lengthens
3813 the archive every time it is used.  The GNU `tar' options intended
3814 specifically for backups are more efficient.  If you need to run
3815 backups, please consult *note Backups::.
3816
3817 \1f
3818 File: tar.info,  Node: concatenate,  Next: delete,  Prev: update,  Up: Advanced tar
3819
3820 4.2.4 Combining Archives with `--concatenate'
3821 ---------------------------------------------
3822
3823 Sometimes it may be convenient to add a second archive onto the end of
3824 an archive rather than adding individual files to the archive.  To add
3825 one or more archives to the end of another archive, you should use the
3826 `--concatenate' (`--catenate', `-A') operation.
3827
3828    To use `--concatenate', give the first archive with `--file' option
3829 and name the rest of archives to be concatenated on the command line.
3830 The members, and their member names, will be copied verbatim from those
3831 archives to the first one.  (1) The new, concatenated archive will be
3832 called by the same name as the one given with the `--file' option.  As
3833 usual, if you omit `--file', `tar' will use the value of the environment
3834 variable `TAPE', or, if this has not been set, the default archive name.
3835
3836    To demonstrate how `--concatenate' works, create two small archives
3837 called `bluesrock.tar' and `folkjazz.tar', using the relevant files
3838 from `practice':
3839
3840      $ tar -cvf bluesrock.tar blues rock
3841      blues
3842      rock
3843      $ tar -cvf folkjazz.tar folk jazz
3844      folk
3845      jazz
3846
3847 If you like, You can run `tar --list' to make sure the archives contain
3848 what they are supposed to:
3849
3850      $ tar -tvf bluesrock.tar
3851      -rw-r--r-- melissa user    105 1997-01-21 19:42 blues
3852      -rw-r--r-- melissa user     33 1997-01-20 15:34 rock
3853      $ tar -tvf jazzfolk.tar
3854      -rw-r--r-- melissa user     20 1996-09-23 16:44 folk
3855      -rw-r--r-- melissa user     65 1997-01-30 14:15 jazz
3856
3857    We can concatenate these two archives with `tar':
3858
3859      $ cd ..
3860      $ tar --concatenate --file=bluesrock.tar jazzfolk.tar
3861
3862    If you now list the contents of the `bluesrock.tar', you will see
3863 that now it also contains the archive members of `jazzfolk.tar':
3864
3865      $ tar --list --file=bluesrock.tar
3866      blues
3867      rock
3868      folk
3869      jazz
3870
3871    When you use `--concatenate', the source and target archives must
3872 already exist and must have been created using compatible format
3873 parameters.  Notice, that `tar' does not check whether the archives it
3874 concatenates have compatible formats, it does not even check if the
3875 files are really tar archives.
3876
3877    Like `--append' (`-r'), this operation cannot be performed on some
3878 tape drives, due to deficiencies in the formats those tape drives use.
3879
3880    It may seem more intuitive to you to want or try to use `cat' to
3881 concatenate two archives instead of using the `--concatenate'
3882 operation; after all, `cat' is the utility for combining files.
3883
3884    However, `tar' archives incorporate an end-of-file marker which must
3885 be removed if the concatenated archives are to be read properly as one
3886 archive.  `--concatenate' removes the end-of-archive marker from the
3887 target archive before each new archive is appended.  If you use `cat'
3888 to combine the archives, the result will not be a valid `tar' format
3889 archive.  If you need to retrieve files from an archive that was added
3890 to using the `cat' utility, use the `--ignore-zeros' (`-i') option.
3891 *Note Ignore Zeros::, for further information on dealing with archives
3892 improperly combined using the `cat' shell utility.
3893
3894    ---------- Footnotes ----------
3895
3896    (1) This can cause multiple members to have the same name, for
3897 information on how this affects reading the archive, *note multiple::.
3898
3899 \1f
3900 File: tar.info,  Node: delete,  Next: compare,  Prev: concatenate,  Up: Advanced tar
3901
3902 4.2.5 Removing Archive Members Using `--delete'
3903 -----------------------------------------------
3904
3905      _(This message will disappear, once this node revised.)_
3906
3907 You can remove members from an archive by using the `--delete' option.
3908 Specify the name of the archive with `--file' (`-f') and then specify
3909 the names of the members to be deleted; if you list no member names,
3910 nothing will be deleted.  The `--verbose' option will cause `tar' to
3911 print the names of the members as they are deleted. As with
3912 `--extract', you must give the exact member names when using `tar
3913 --delete'.  `--delete' will remove all versions of the named file from
3914 the archive.  The `--delete' operation can run very slowly.
3915
3916    Unlike other operations, `--delete' has no short form.
3917
3918    This operation will rewrite the archive.  You can only use
3919 `--delete' on an archive if the archive device allows you to write to
3920 any point on the media, such as a disk; because of this, it does not
3921 work on magnetic tapes.  Do not try to delete an archive member from a
3922 magnetic tape; the action will not succeed, and you will be likely to
3923 scramble the archive and damage your tape.  There is no safe way
3924 (except by completely re-writing the archive) to delete files from most
3925 kinds of magnetic tape.  *Note Media::.
3926
3927    To delete all versions of the file `blues' from the archive
3928 `collection.tar' in the `practice' directory, make sure you are in that
3929 directory, and then,
3930
3931      $ tar --list --file=collection.tar
3932      blues
3933      folk
3934      jazz
3935      rock
3936      $ tar --delete --file=collection.tar blues
3937      $ tar --list --file=collection.tar
3938      folk
3939      jazz
3940      rock
3941      $
3942
3943    The `--delete' option has been reported to work properly when `tar'
3944 acts as a filter from `stdin' to `stdout'.
3945
3946 \1f
3947 File: tar.info,  Node: compare,  Prev: delete,  Up: Advanced tar
3948
3949 4.2.6 Comparing Archive Members with the File System
3950 ----------------------------------------------------
3951
3952      _(This message will disappear, once this node revised.)_
3953
3954 The `--compare' (`-d'), or `--diff' operation compares specified
3955 archive members against files with the same names, and then reports
3956 differences in file size, mode, owner, modification date and contents.
3957 You should _only_ specify archive member names, not file names.  If you
3958 do not name any members, then `tar' will compare the entire archive.
3959 If a file is represented in the archive but does not exist in the file
3960 system, `tar' reports a difference.
3961
3962    You have to specify the record size of the archive when modifying an
3963 archive with a non-default record size.
3964
3965    `tar' ignores files in the file system that do not have
3966 corresponding members in the archive.
3967
3968    The following example compares the archive members `rock', `blues'
3969 and `funk' in the archive `bluesrock.tar' with files of the same name
3970 in the file system.  (Note that there is no file, `funk'; `tar' will
3971 report an error message.)
3972
3973      $ tar --compare --file=bluesrock.tar rock blues funk
3974      rock
3975      blues
3976      tar: funk not found in archive
3977
3978    The spirit behind the `--compare' (`--diff', `-d') option is to
3979 check whether the archive represents the current state of files on
3980 disk, more than validating the integrity of the archive media.  For
3981 this later goal, *Note verify::.
3982
3983 \1f
3984 File: tar.info,  Node: create options,  Next: extract options,  Prev: Advanced tar,  Up: operations
3985
3986 4.3 Options Used by `--create'
3987 ==============================
3988
3989 The previous chapter described the basics of how to use `--create'
3990 (`-c') to create an archive from a set of files.  *Note create::.  This
3991 section described advanced options to be used with `--create'.
3992
3993 * Menu:
3994
3995 * override::                  Overriding File Metadata.
3996 * Ignore Failed Read::
3997
3998 \1f
3999 File: tar.info,  Node: override,  Next: Ignore Failed Read,  Up: create options
4000
4001 4.3.1 Overriding File Metadata
4002 ------------------------------
4003
4004 As described above, a `tar' archive keeps, for each member it contains,
4005 its "metadata", such as modification time, mode and ownership of the
4006 file.  GNU `tar' allows to replace these data with other values when
4007 adding files to the archive.  The options described in this section
4008 affect creation of archives of any type.  For POSIX archives, see also
4009 *note PAX keywords::, for additional ways of controlling metadata,
4010 stored in the archive.
4011
4012 `--mode=PERMISSIONS'
4013      When adding files to an archive, `tar' will use PERMISSIONS for
4014      the archive members, rather than the permissions from the files.
4015      PERMISSIONS can be specified either as an octal number or as
4016      symbolic permissions, like with `chmod' (*Note Permissions:
4017      (fileutils)File permissions.  This reference also has useful
4018      information for those not being overly familiar with the UNIX
4019      permission system).  Using latter syntax allows for more
4020      flexibility.  For example, the value `a+rw' adds read and write
4021      permissions for everybody, while retaining executable bits on
4022      directories or on any other file already marked as executable:
4023
4024           $ tar -c -f archive.tar --mode='a+rw' .
4025
4026 `--mtime=DATE'
4027      When adding files to an archive, `tar' will use DATE as the
4028      modification time of members when creating archives, instead of
4029      their actual modification times.  The argument DATE can be either
4030      a textual date representation in almost arbitrary format (*note
4031      Date input formats::) or a name of the existing file, starting
4032      with `/' or `.'.  In the latter case, the modification time of
4033      that file will be used.
4034
4035      The following example will set the modification date to 00:00:00
4036      UTC, January 1, 1970:
4037
4038           $ tar -c -f archive.tar --mtime='1970-01-01' .
4039
4040      When used with `--verbose' (*note verbose tutorial::) GNU `tar'
4041      will try to convert the specified date back to its textual
4042      representation and compare it with the one given with `--mtime'
4043      options.  If the two dates differ, `tar' will print a warning
4044      saying what date it will use.  This is to help user ensure he is
4045      using the right date.
4046
4047      For example:
4048
4049           $ tar -c -f archive.tar -v --mtime=yesterday .
4050           tar: Option --mtime: Treating date `yesterday' as 2006-06-20
4051           13:06:29.152478
4052           ...
4053
4054 `--owner=USER'
4055      Specifies that `tar' should use USER as the owner of members when
4056      creating archives, instead of the user associated with the source
4057      file.  The argument USER can be either an existing user symbolic
4058      name, or a decimal numeric user ID.
4059
4060      There is no value indicating a missing number, and `0' usually
4061      means `root'.  Some people like to force `0' as the value to offer
4062      in their distributions for the owner of files, because the `root'
4063      user is anonymous anyway, so that might as well be the owner of
4064      anonymous archives.  For example:
4065
4066           $ tar -c -f archive.tar --owner=0 .
4067           # Or:
4068           $ tar -c -f archive.tar --owner=root .
4069
4070 `--group=GROUP'
4071      Files added to the `tar' archive will have a group ID of GROUP,
4072      rather than the group from the source file.  The argument GROUP
4073      can be either an existing group symbolic name, or a decimal
4074      numeric group ID.
4075
4076 \1f
4077 File: tar.info,  Node: Ignore Failed Read,  Prev: override,  Up: create options
4078
4079 4.3.2 Ignore Fail Read
4080 ----------------------
4081
4082 `--ignore-failed-read'
4083      Do not exit with nonzero on unreadable files or directories.
4084
4085 \1f
4086 File: tar.info,  Node: extract options,  Next: backup,  Prev: create options,  Up: operations
4087
4088 4.4 Options Used by `--extract'
4089 ===============================
4090
4091      _(This message will disappear, once this node revised.)_
4092
4093 The previous chapter showed how to use `--extract' to extract an
4094 archive into the file system.  Various options cause `tar' to extract
4095 more information than just file contents, such as the owner, the
4096 permissions, the modification date, and so forth.  This section
4097 presents options to be used with `--extract' when certain special
4098 considerations arise.  You may review the information presented in
4099 *note extract:: for more basic information about the `--extract'
4100 operation.
4101
4102 * Menu:
4103
4104 * Reading::                     Options to Help Read Archives
4105 * Writing::                     Changing How `tar' Writes Files
4106 * Scarce::                      Coping with Scarce Resources
4107
4108 \1f
4109 File: tar.info,  Node: Reading,  Next: Writing,  Up: extract options
4110
4111 4.4.1 Options to Help Read Archives
4112 -----------------------------------
4113
4114      _(This message will disappear, once this node revised.)_
4115
4116 Normally, `tar' will request data in full record increments from an
4117 archive storage device.  If the device cannot return a full record,
4118 `tar' will report an error.  However, some devices do not always return
4119 full records, or do not require the last record of an archive to be
4120 padded out to the next record boundary.  To keep reading until you
4121 obtain a full record, or to accept an incomplete record if it contains
4122 an end-of-archive marker, specify the `--read-full-records' (`-B')
4123 option in conjunction with the `--extract' or `--list' operations.
4124 *Note Blocking::.
4125
4126    The `--read-full-records' (`-B') option is turned on by default when
4127 `tar' reads an archive from standard input, or from a remote machine.
4128 This is because on BSD Unix systems, attempting to read a pipe returns
4129 however much happens to be in the pipe, even if it is less than was
4130 requested.  If this option were not enabled, `tar' would fail as soon
4131 as it read an incomplete record from the pipe.
4132
4133    If you're not sure of the blocking factor of an archive, you can
4134 read the archive by specifying `--read-full-records' (`-B') and
4135 `--blocking-factor=512-SIZE' (`-b 512-SIZE'), using a blocking factor
4136 larger than what the archive uses.  This lets you avoid having to
4137 determine the blocking factor of an archive.  *Note Blocking Factor::.
4138
4139 * Menu:
4140
4141 * read full records::
4142 * Ignore Zeros::
4143
4144 \1f
4145 File: tar.info,  Node: read full records,  Next: Ignore Zeros,  Up: Reading
4146
4147 Reading Full Records
4148 ....................
4149
4150 `--read-full-records'
4151
4152 `-B'
4153      Use in conjunction with `--extract' (`--get', `-x') to read an
4154      archive which contains incomplete records, or one which has a
4155      blocking factor less than the one specified.
4156
4157 \1f
4158 File: tar.info,  Node: Ignore Zeros,  Prev: read full records,  Up: Reading
4159
4160 Ignoring Blocks of Zeros
4161 ........................
4162
4163 Normally, `tar' stops reading when it encounters a block of zeros
4164 between file entries (which usually indicates the end of the archive).
4165 `--ignore-zeros' (`-i') allows `tar' to completely read an archive
4166 which contains a block of zeros before the end (i.e., a damaged
4167 archive, or one that was created by concatenating several archives
4168 together).
4169
4170    The `--ignore-zeros' (`-i') option is turned off by default because
4171 many versions of `tar' write garbage after the end-of-archive entry,
4172 since that part of the media is never supposed to be read.  GNU `tar'
4173 does not write after the end of an archive, but seeks to maintain
4174 compatibility among archiving utilities.
4175
4176 `--ignore-zeros'
4177 `-i'
4178      To ignore blocks of zeros (i.e., end-of-archive entries) which may
4179      be encountered while reading an archive.  Use in conjunction with
4180      `--extract' or `--list'.
4181
4182 \1f
4183 File: tar.info,  Node: Writing,  Next: Scarce,  Prev: Reading,  Up: extract options
4184
4185 4.4.2 Changing How `tar' Writes Files
4186 -------------------------------------
4187
4188      _(This message will disappear, once this node revised.)_
4189
4190 * Menu:
4191
4192 * Dealing with Old Files::
4193 * Overwrite Old Files::
4194 * Keep Old Files::
4195 * Keep Newer Files::
4196 * Unlink First::
4197 * Recursive Unlink::
4198 * Data Modification Times::
4199 * Setting Access Permissions::
4200 * Directory Modification Times and Permissions::
4201 * Writing to Standard Output::
4202 * Writing to an External Program::
4203 * remove files::
4204
4205 \1f
4206 File: tar.info,  Node: Dealing with Old Files,  Next: Overwrite Old Files,  Up: Writing
4207
4208 Options Controlling the Overwriting of Existing Files
4209 .....................................................
4210
4211 When extracting files, if `tar' discovers that the extracted file
4212 already exists, it normally replaces the file by removing it before
4213 extracting it, to prevent confusion in the presence of hard or symbolic
4214 links.  (If the existing file is a symbolic link, it is removed, not
4215 followed.)  However, if a directory cannot be removed because it is
4216 nonempty, `tar' normally overwrites its metadata (ownership,
4217 permission, etc.).  The `--overwrite-dir' option enables this default
4218 behavior.  To be more cautious and preserve the metadata of such a
4219 directory, use the `--no-overwrite-dir' option.
4220
4221    To be even more cautious and prevent existing files from being
4222 replaced, use the `--keep-old-files' (`-k') option.  It causes `tar' to
4223 refuse to replace or update a file that already exists, i.e., a file
4224 with the same name as an archive member prevents extraction of that
4225 archive member.  Instead, it reports an error.
4226
4227    To be more aggressive about altering existing files, use the
4228 `--overwrite' option.  It causes `tar' to overwrite existing files and
4229 to follow existing symbolic links when extracting.
4230
4231    Some people argue that GNU `tar' should not hesitate to overwrite
4232 files with other files when extracting.  When extracting a `tar'
4233 archive, they expect to see a faithful copy of the state of the file
4234 system when the archive was created.  It is debatable that this would
4235 always be a proper behavior.  For example, suppose one has an archive
4236 in which `usr/local' is a link to `usr/local2'.  Since then, maybe the
4237 site removed the link and renamed the whole hierarchy from
4238 `/usr/local2' to `/usr/local'.  Such things happen all the time.  I
4239 guess it would not be welcome at all that GNU `tar' removes the whole
4240 hierarchy just to make room for the link to be reinstated (unless it
4241 _also_ simultaneously restores the full `/usr/local2', of course!)  GNU
4242 `tar' is indeed able to remove a whole hierarchy to reestablish a
4243 symbolic link, for example, but _only if_ `--recursive-unlink' is
4244 specified to allow this behavior.  In any case, single files are
4245 silently removed.
4246
4247    Finally, the `--unlink-first' (`-U') option can improve performance
4248 in some cases by causing `tar' to remove files unconditionally before
4249 extracting them.
4250
4251 \1f
4252 File: tar.info,  Node: Overwrite Old Files,  Next: Keep Old Files,  Prev: Dealing with Old Files,  Up: Writing
4253
4254 Overwrite Old Files
4255 ...................
4256
4257 `--overwrite'
4258      Overwrite existing files and directory metadata when extracting
4259      files from an archive.
4260
4261      This causes `tar' to write extracted files into the file system
4262      without regard to the files already on the system; i.e., files
4263      with the same names as archive members are overwritten when the
4264      archive is extracted.  It also causes `tar' to extract the
4265      ownership, permissions, and time stamps onto any preexisting files
4266      or directories.  If the name of a corresponding file name is a
4267      symbolic link, the file pointed to by the symbolic link will be
4268      overwritten instead of the symbolic link itself (if this is
4269      possible).  Moreover, special devices, empty directories and even
4270      symbolic links are automatically removed if they are in the way of
4271      extraction.
4272
4273      Be careful when using the `--overwrite' option, particularly when
4274      combined with the `--absolute-names' (`-P') option, as this
4275      combination can change the contents, ownership or permissions of
4276      any file on your system.  Also, many systems do not take kindly to
4277      overwriting files that are currently being executed.
4278
4279 `--overwrite-dir'
4280      Overwrite the metadata of directories when extracting files from an
4281      archive, but remove other files before extracting.
4282
4283 \1f
4284 File: tar.info,  Node: Keep Old Files,  Next: Keep Newer Files,  Prev: Overwrite Old Files,  Up: Writing
4285
4286 Keep Old Files
4287 ..............
4288
4289 `--keep-old-files'
4290 `-k'
4291      Do not replace existing files from archive.  The
4292      `--keep-old-files' (`-k') option prevents `tar' from replacing
4293      existing files with files with the same name from the archive. The
4294      `--keep-old-files' option is meaningless with `--list' (`-t').
4295      Prevents `tar' from replacing files in the file system during
4296      extraction.
4297
4298 \1f
4299 File: tar.info,  Node: Keep Newer Files,  Next: Unlink First,  Prev: Keep Old Files,  Up: Writing
4300
4301 Keep Newer Files
4302 ................
4303
4304 `--keep-newer-files'
4305      Do not replace existing files that are newer than their archive
4306      copies.  This option is meaningless with `--list' (`-t').
4307
4308 \1f
4309 File: tar.info,  Node: Unlink First,  Next: Recursive Unlink,  Prev: Keep Newer Files,  Up: Writing
4310
4311 Unlink First
4312 ............
4313
4314 `--unlink-first'
4315 `-U'
4316      Remove files before extracting over them.  This can make `tar' run
4317      a bit faster if you know in advance that the extracted files all
4318      need to be removed.  Normally this option slows `tar' down
4319      slightly, so it is disabled by default.
4320
4321 \1f
4322 File: tar.info,  Node: Recursive Unlink,  Next: Data Modification Times,  Prev: Unlink First,  Up: Writing
4323
4324 Recursive Unlink
4325 ................
4326
4327 `--recursive-unlink'
4328      When this option is specified, try removing files and directory
4329      hierarchies before extracting over them.  _This is a dangerous
4330      option!_
4331
4332    If you specify the `--recursive-unlink' option, `tar' removes
4333 _anything_ that keeps you from extracting a file as far as current
4334 permissions will allow it.  This could include removal of the contents
4335 of a full directory hierarchy.
4336
4337 \1f
4338 File: tar.info,  Node: Data Modification Times,  Next: Setting Access Permissions,  Prev: Recursive Unlink,  Up: Writing
4339
4340 Setting Data Modification Times
4341 ...............................
4342
4343 Normally, `tar' sets the data modification times of extracted files to
4344 the corresponding times recorded for the files in the archive, but
4345 limits the permissions of extracted files by the current `umask'
4346 setting.
4347
4348    To set the data modification times of extracted files to the time
4349 when the files were extracted, use the `--touch' (`-m') option in
4350 conjunction with `--extract' (`--get', `-x').
4351
4352 `--touch'
4353 `-m'
4354      Sets the data modification time of extracted archive members to
4355      the time they were extracted, not the time recorded for them in
4356      the archive.  Use in conjunction with `--extract' (`--get', `-x').
4357
4358 \1f
4359 File: tar.info,  Node: Setting Access Permissions,  Next: Directory Modification Times and Permissions,  Prev: Data Modification Times,  Up: Writing
4360
4361 Setting Access Permissions
4362 ..........................
4363
4364 To set the modes (access permissions) of extracted files to those
4365 recorded for those files in the archive, use `--same-permissions' in
4366 conjunction with the `--extract' (`--get', `-x') operation.
4367
4368 `--preserve-permissions'
4369 `--same-permissions'
4370 `-p'
4371      Set modes of extracted archive members to those recorded in the
4372      archive, instead of current umask settings.  Use in conjunction
4373      with `--extract' (`--get', `-x').
4374
4375 \1f
4376 File: tar.info,  Node: Directory Modification Times and Permissions,  Next: Writing to Standard Output,  Prev: Setting Access Permissions,  Up: Writing
4377
4378 Directory Modification Times and Permissions
4379 ............................................
4380
4381 After successfully extracting a file member, GNU `tar' normally
4382 restores its permissions and modification times, as described in the
4383 previous sections.  This cannot be done for directories, because after
4384 extracting a directory `tar' will almost certainly extract files into
4385 that directory and this will cause the directory modification time to
4386 be updated.  Moreover, restoring that directory permissions may not
4387 permit file creation within it.  Thus, restoring directory permissions
4388 and modification times must be delayed at least until all files have
4389 been extracted into that directory.  GNU `tar' restores directories
4390 using the following approach.
4391
4392    The extracted directories are created with the mode specified in the
4393 archive, as modified by the umask of the user, which gives sufficient
4394 permissions to allow file creation.  The meta-information about the
4395 directory is recorded in the temporary list of directories.  When
4396 preparing to extract next archive member, GNU `tar' checks if the
4397 directory prefix of this file contains the remembered directory.  If it
4398 does not, the program assumes that all files have been extracted into
4399 that directory, restores its modification time and permissions and
4400 removes its entry from the internal list.  This approach allows to
4401 correctly restore directory meta-information in the majority of cases,
4402 while keeping memory requirements sufficiently small.  It is based on
4403 the fact, that most `tar' archives use the predefined order of members:
4404 first the directory, then all the files and subdirectories in that
4405 directory.
4406
4407    However, this is not always true.  The most important exception are
4408 incremental archives (*note Incremental Dumps::).  The member order in
4409 an incremental archive is reversed: first all directory members are
4410 stored, followed by other (non-directory) members.  So, when extracting
4411 from incremental archives, GNU `tar' alters the above procedure.  It
4412 remembers all restored directories, and restores their meta-data only
4413 after the entire archive has been processed.  Notice, that you do not
4414 need to specify any special options for that, as GNU `tar'
4415 automatically detects archives in incremental format.
4416
4417    There may be cases, when such processing is required for normal
4418 archives too.  Consider the following example:
4419
4420      $ tar --no-recursion -cvf archive \
4421          foo foo/file1 bar bar/file foo/file2
4422      foo/
4423      foo/file1
4424      bar/
4425      bar/file
4426      foo/file2
4427
4428    During the normal operation, after encountering `bar' GNU `tar' will
4429 assume that all files from the directory `foo' were already extracted
4430 and will therefore restore its timestamp and permission bits.  However,
4431 after extracting `foo/file2' the directory timestamp will be offset
4432 again.
4433
4434    To correctly restore directory meta-information in such cases, use
4435 `delay-directory-restore' command line option:
4436
4437 `--delay-directory-restore'
4438      Delays restoring of the modification times and permissions of
4439      extracted directories until the end of extraction.  This way,
4440      correct meta-information is restored even if the archive has
4441      unusual member ordering.
4442
4443 `--no-delay-directory-restore'
4444      Cancel the effect of the previous `--delay-directory-restore'.
4445      Use this option if you have used `--delay-directory-restore' in
4446      `TAR_OPTIONS' variable (*note TAR_OPTIONS::) and wish to
4447      temporarily disable it.
4448
4449 \1f
4450 File: tar.info,  Node: Writing to Standard Output,  Next: Writing to an External Program,  Prev: Directory Modification Times and Permissions,  Up: Writing
4451
4452 Writing to Standard Output
4453 ..........................
4454
4455 To write the extracted files to the standard output, instead of
4456 creating the files on the file system, use `--to-stdout' (`-O') in
4457 conjunction with `--extract' (`--get', `-x').  This option is useful if
4458 you are extracting files to send them through a pipe, and do not need to
4459 preserve them in the file system.  If you extract multiple members,
4460 they appear on standard output concatenated, in the order they are
4461 found in the archive.
4462
4463 `--to-stdout'
4464 `-O'
4465      Writes files to the standard output.  Use only in conjunction with
4466      `--extract' (`--get', `-x').  When this option is used, instead of
4467      creating the files specified, `tar' writes the contents of the
4468      files extracted to its standard output.  This may be useful if you
4469      are only extracting the files in order to send them through a
4470      pipe.  This option is meaningless with `--list' (`-t').
4471
4472    This can be useful, for example, if you have a tar archive containing
4473 a big file and don't want to store the file on disk before processing
4474 it.  You can use a command like this:
4475
4476      tar -xOzf foo.tgz bigfile | process
4477
4478    or even like this if you want to process the concatenation of the
4479 files:
4480
4481      tar -xOzf foo.tgz bigfile1 bigfile2 | process
4482
4483    However, `--to-command' may be more convenient for use with multiple
4484 files. See the next section.
4485
4486 \1f
4487 File: tar.info,  Node: Writing to an External Program,  Next: remove files,  Prev: Writing to Standard Output,  Up: Writing
4488
4489 Writing to an External Program
4490 ..............................
4491
4492 You can instruct `tar' to send the contents of each extracted file to
4493 the standard input of an external program:
4494
4495 `--to-command=COMMAND'
4496      Extract files and pipe their contents to the standard input of
4497      COMMAND. When this option is used, instead of creating the files
4498      specified, `tar' invokes COMMAND and pipes the contents of the
4499      files to its standard output. COMMAND may contain command line
4500      arguments. The program is executed via `sh -c'. Notice, that
4501      COMMAND is executed once for each regular file extracted.
4502      Non-regular files (directories, etc.) are ignored when this option
4503      is used.
4504
4505    The command can obtain the information about the file it processes
4506 from the following environment variables:
4507
4508 `TAR_FILETYPE'
4509      Type of the file. It is a single letter with the following meaning:
4510
4511      f       Regular file
4512      d       Directory
4513      l       Symbolic link
4514      h       Hard link
4515      b       Block device
4516      c       Character device
4517
4518      Currently only regular files are supported.
4519
4520 `TAR_MODE'
4521      File mode, an octal number.
4522
4523 `TAR_FILENAME'
4524      The name of the file.
4525
4526 `TAR_REALNAME'
4527      Name of the file as stored in the archive.
4528
4529 `TAR_UNAME'
4530      Name of the file owner.
4531
4532 `TAR_GNAME'
4533      Name of the file owner group.
4534
4535 `TAR_ATIME'
4536      Time of last access. It is a decimal number, representing seconds
4537      since the epoch.  If the archive provides times with nanosecond
4538      precision, the nanoseconds are appended to the timestamp after a
4539      decimal point.
4540
4541 `TAR_MTIME'
4542      Time of last modification.
4543
4544 `TAR_CTIME'
4545      Time of last status change.
4546
4547 `TAR_SIZE'
4548      Size of the file.
4549
4550 `TAR_UID'
4551      UID of the file owner.
4552
4553 `TAR_GID'
4554      GID of the file owner.
4555
4556    In addition to these variables, `TAR_VERSION' contains the GNU `tar'
4557 version number.
4558
4559    If COMMAND exits with a non-0 status, `tar' will print an error
4560 message similar to the following:
4561
4562      tar: 2345: Child returned status 1
4563
4564    Here, `2345' is the PID of the finished process.
4565
4566    If this behavior is not wanted, use `--ignore-command-error':
4567
4568 `--ignore-command-error'
4569      Ignore exit codes of subprocesses.  Notice that if the program
4570      exits on signal or otherwise terminates abnormally, the error
4571      message will be printed even if this option is used.
4572
4573 `--no-ignore-command-error'
4574      Cancel the effect of any previous `--ignore-command-error' option.
4575      This option is useful if you have set `--ignore-command-error' in
4576      `TAR_OPTIONS' (*note TAR_OPTIONS::) and wish to temporarily cancel
4577      it.
4578
4579 \1f
4580 File: tar.info,  Node: remove files,  Prev: Writing to an External Program,  Up: Writing
4581
4582 Removing Files
4583 ..............
4584
4585 `--remove-files'
4586      Remove files after adding them to the archive.
4587
4588 \1f
4589 File: tar.info,  Node: Scarce,  Prev: Writing,  Up: extract options
4590
4591 4.4.3 Coping with Scarce Resources
4592 ----------------------------------
4593
4594      _(This message will disappear, once this node revised.)_
4595
4596 * Menu:
4597
4598 * Starting File::
4599 * Same Order::
4600
4601 \1f
4602 File: tar.info,  Node: Starting File,  Next: Same Order,  Up: Scarce
4603
4604 Starting File
4605 .............
4606
4607 `--starting-file=NAME'
4608 `-K NAME'
4609      Starts an operation in the middle of an archive.  Use in
4610      conjunction with `--extract' (`--get', `-x') or `--list' (`-t').
4611
4612    If a previous attempt to extract files failed due to lack of disk
4613 space, you can use `--starting-file=NAME' (`-K NAME') to start
4614 extracting only after member NAME of the archive.  This assumes, of
4615 course, that there is now free space, or that you are now extracting
4616 into a different file system.  (You could also choose to suspend `tar',
4617 remove unnecessary files from the file system, and then restart the
4618 same `tar' operation.  In this case, `--starting-file' is not necessary.
4619 *Note Incremental Dumps::, *Note interactive::, and *note exclude::.)
4620
4621 \1f
4622 File: tar.info,  Node: Same Order,  Prev: Starting File,  Up: Scarce
4623
4624 Same Order
4625 ..........
4626
4627 `--same-order'
4628 `--preserve-order'
4629 `-s'
4630      To process large lists of file names on machines with small
4631      amounts of memory.  Use in conjunction with `--compare' (`--diff',
4632      `-d'), `--list' (`-t') or `--extract' (`--get', `-x').
4633
4634    The `--same-order' (`--preserve-order', `-s') option tells `tar'
4635 that the list of file names to be listed or extracted is sorted in the
4636 same order as the files in the archive.  This allows a large list of
4637 names to be used, even on a small machine that would not otherwise be
4638 able to hold all the names in memory at the same time.  Such a sorted
4639 list can easily be created by running `tar -t' on the archive and
4640 editing its output.
4641
4642    This option is probably never needed on modern computer systems.
4643
4644 \1f
4645 File: tar.info,  Node: backup,  Next: Applications,  Prev: extract options,  Up: operations
4646
4647 4.5 Backup options
4648 ==================
4649
4650 GNU `tar' offers options for making backups of files before writing new
4651 versions.  These options control the details of these backups.  They
4652 may apply to the archive itself before it is created or rewritten, as
4653 well as individual extracted members.  Other GNU programs (`cp',
4654 `install', `ln', and `mv', for example) offer similar options.
4655
4656    Backup options may prove unexpectedly useful when extracting archives
4657 containing many members having identical name, or when extracting
4658 archives on systems having file name limitations, making different
4659 members appear has having similar names through the side-effect of name
4660 truncation.  (This is true only if we have a good scheme for truncated
4661 backup names, which I'm not sure at all: I suspect work is needed in
4662 this area.)  When any existing file is backed up before being
4663 overwritten by extraction, then clashing files are automatically be
4664 renamed to be unique, and the true name is kept for only the last file
4665 of a series of clashing files.  By using verbose mode, users may track
4666 exactly what happens.
4667
4668    At the detail level, some decisions are still experimental, and may
4669 change in the future, we are waiting comments from our users.  So,
4670 please do not learn to depend blindly on the details of the backup
4671 features.  For example, currently, directories themselves are never
4672 renamed through using these options, so, extracting a file over a
4673 directory still has good chances to fail.  Also, backup options apply
4674 to created archives, not only to extracted members.  For created
4675 archives, backups will not be attempted when the archive is a block or
4676 character device, or when it refers to a remote file.
4677
4678    For the sake of simplicity and efficiency, backups are made by
4679 renaming old files prior to creation or extraction, and not by copying.
4680 The original name is restored if the file creation fails.  If a failure
4681 occurs after a partial extraction of a file, both the backup and the
4682 partially extracted file are kept.
4683
4684 `--backup[=METHOD]'
4685      Back up files that are about to be overwritten or removed.
4686      Without this option, the original versions are destroyed.
4687
4688      Use METHOD to determine the type of backups made.  If METHOD is
4689      not specified, use the value of the `VERSION_CONTROL' environment
4690      variable.  And if `VERSION_CONTROL' is not set, use the `existing'
4691      method.
4692
4693      This option corresponds to the Emacs variable `version-control';
4694      the same values for METHOD are accepted as in Emacs.  This option
4695      also allows more descriptive names.  The valid METHODs are:
4696
4697     `t'
4698     `numbered'
4699           Always make numbered backups.
4700
4701     `nil'
4702     `existing'
4703           Make numbered backups of files that already have them, simple
4704           backups of the others.
4705
4706     `never'
4707     `simple'
4708           Always make simple backups.
4709
4710
4711 `--suffix=SUFFIX'
4712      Append SUFFIX to each backup file made with `--backup'.  If this
4713      option is not specified, the value of the `SIMPLE_BACKUP_SUFFIX'
4714      environment variable is used.  And if `SIMPLE_BACKUP_SUFFIX' is not
4715      set, the default is `~', just as in Emacs.
4716
4717
4718 \1f
4719 File: tar.info,  Node: Applications,  Next: looking ahead,  Prev: backup,  Up: operations
4720
4721 4.6 Notable `tar' Usages
4722 ========================
4723
4724      _(This message will disappear, once this node revised.)_
4725
4726 You can easily use archive files to transport a group of files from one
4727 system to another: put all relevant files into an archive on one
4728 computer system, transfer the archive to another system, and extract
4729 the contents there.  The basic transfer medium might be magnetic tape,
4730 Internet FTP, or even electronic mail (though you must encode the
4731 archive with `uuencode' in order to transport it properly by mail).
4732 Both machines do not have to use the same operating system, as long as
4733 they both support the `tar' program.
4734
4735    For example, here is how you might copy a directory's contents from
4736 one disk to another, while preserving the dates, modes, owners and
4737 link-structure of all the files therein.  In this case, the transfer
4738 medium is a "pipe", which is one a Unix redirection mechanism:
4739
4740      $ (cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)
4741
4742 You can avoid subshells by using `-C' option:
4743
4744      $ tar -C sourcedir -cf - . | tar -C targetdir -xf -
4745
4746 The command also works using short option forms:
4747
4748      $ (cd sourcedir; tar --create --file=- . ) \
4749             | (cd targetdir; tar --extract --file=-)
4750      # Or:
4751      $ tar --directory sourcedir --create --file=- . ) \
4752             | tar --directory targetdir --extract --file=-
4753
4754 This is one of the easiest methods to transfer a `tar' archive.
4755
4756 \1f
4757 File: tar.info,  Node: looking ahead,  Prev: Applications,  Up: operations
4758
4759 4.7 Looking Ahead: The Rest of this Manual
4760 ==========================================
4761
4762 You have now seen how to use all eight of the operations available to
4763 `tar', and a number of the possible options.  The next chapter explains
4764 how to choose and change file and archive names, how to use files to
4765 store names of other files which you can then call as arguments to
4766 `tar' (this can help you save time if you expect to archive the same
4767 list of files a number of times), and so forth.
4768
4769    If there are too many files to conveniently list on the command line,
4770 you can list the names in a file, and `tar' will read that file.  *Note
4771 files::.
4772
4773    There are various ways of causing `tar' to skip over some files, and
4774 not archive them.  *Note Choosing::.
4775
4776 \1f
4777 File: tar.info,  Node: Backups,  Next: Choosing,  Prev: operations,  Up: Top
4778
4779 5 Performing Backups and Restoring Files
4780 ****************************************
4781
4782      _(This message will disappear, once this node revised.)_
4783
4784 GNU `tar' is distributed along with the scripts which the Free Software
4785 Foundation uses for performing backups.  There is no corresponding
4786 scripts available yet for doing restoration of files.  Even if there is
4787 a good chance those scripts may be satisfying to you, they are not the
4788 only scripts or methods available for doing backups and restore.  You
4789 may well create your own, or use more sophisticated packages dedicated
4790 to that purpose.
4791
4792    Some users are enthusiastic about `Amanda' (The Advanced Maryland
4793 Automatic Network Disk Archiver), a backup system developed by James da
4794 Silva `jds@cs.umd.edu' and available on many Unix systems.  This is
4795 free software, and it is available at these places:
4796
4797      http://www.cs.umd.edu/projects/amanda/amanda.html
4798      ftp://ftp.cs.umd.edu/pub/amanda
4799
4800    This chapter documents both the provided shell scripts and `tar'
4801 options which are more specific to usage as a backup tool.
4802
4803    To "back up" a file system means to create archives that contain all
4804 the files in that file system.  Those archives can then be used to
4805 restore any or all of those files (for instance if a disk crashes or a
4806 file is accidentally deleted).  File system "backups" are also called
4807 "dumps".
4808
4809 * Menu:
4810
4811 * Full Dumps::                  Using `tar' to Perform Full Dumps
4812 * Incremental Dumps::           Using `tar' to Perform Incremental Dumps
4813 * Backup Levels::               Levels of Backups
4814 * Backup Parameters::           Setting Parameters for Backups and Restoration
4815 * Scripted Backups::            Using the Backup Scripts
4816 * Scripted Restoration::        Using the Restore Script
4817
4818 \1f
4819 File: tar.info,  Node: Full Dumps,  Next: Incremental Dumps,  Up: Backups
4820
4821 5.1 Using `tar' to Perform Full Dumps
4822 =====================================
4823
4824      _(This message will disappear, once this node revised.)_
4825
4826 Full dumps should only be made when no other people or programs are
4827 modifying files in the file system.  If files are modified while `tar'
4828 is making the backup, they may not be stored properly in the archive,
4829 in which case you won't be able to restore them if you have to.  (Files
4830 not being modified are written with no trouble, and do not corrupt the
4831 entire archive.)
4832
4833    You will want to use the `--label=ARCHIVE-LABEL' (`-V
4834 ARCHIVE-LABEL') option to give the archive a volume label, so you can
4835 tell what this archive is even if the label falls off the tape, or
4836 anything like that.
4837
4838    Unless the file system you are dumping is guaranteed to fit on one
4839 volume, you will need to use the `--multi-volume' (`-M') option.  Make
4840 sure you have enough tapes on hand to complete the backup.
4841
4842    If you want to dump each file system separately you will need to use
4843 the `--one-file-system' option to prevent `tar' from crossing file
4844 system boundaries when storing (sub)directories.
4845
4846    The `--incremental' (`-G') (*note Incremental Dumps::) option is not
4847 needed, since this is a complete copy of everything in the file system,
4848 and a full restore from this backup would only be done onto a completely
4849 empty disk.
4850
4851    Unless you are in a hurry, and trust the `tar' program (and your
4852 tapes), it is a good idea to use the `--verify' (`-W') option, to make
4853 sure your files really made it onto the dump properly.  This will also
4854 detect cases where the file was modified while (or just after) it was
4855 being archived.  Not all media (notably cartridge tapes) are capable of
4856 being verified, unfortunately.
4857
4858 \1f
4859 File: tar.info,  Node: Incremental Dumps,  Next: Backup Levels,  Prev: Full Dumps,  Up: Backups
4860
4861 5.2 Using `tar' to Perform Incremental Dumps
4862 ============================================
4863
4864 "Incremental backup" is a special form of GNU `tar' archive that stores
4865 additional metadata so that exact state of the file system can be
4866 restored when extracting the archive.
4867
4868    GNU `tar' currently offers two options for handling incremental
4869 backups: `--listed-incremental=SNAPSHOT-FILE' (`-g SNAPSHOT-FILE') and
4870 `--incremental' (`-G').
4871
4872    The option `--listed-incremental' instructs tar to operate on an
4873 incremental archive with additional metadata stored in a standalone
4874 file, called a "snapshot file".  The purpose of this file is to help
4875 determine which files have been changed, added or deleted since the
4876 last backup, so that the next incremental backup will contain only
4877 modified files.  The name of the snapshot file is given as an argument
4878 to the option:
4879
4880 `--listed-incremental=FILE'
4881 `-g FILE'
4882      Handle incremental backups with snapshot data in FILE.
4883
4884    To create an incremental backup, you would use
4885 `--listed-incremental' together with `--create' (*note create::).  For
4886 example:
4887
4888      $ tar --create \
4889                 --file=archive.1.tar \
4890                 --listed-incremental=/var/log/usr.snar \
4891                 /usr
4892
4893    This will create in `archive.1.tar' an incremental backup of the
4894 `/usr' file system, storing additional metadata in the file
4895 `/var/log/usr.snar'.  If this file does not exist, it will be created.
4896 The created archive will then be a "level 0 backup"; please see the
4897 next section for more on backup levels.
4898
4899    Otherwise, if the file `/var/log/usr.snar' exists, it determines
4900 which files are modified.  In this case only these files will be stored
4901 in the archive.  Suppose, for example, that after running the above
4902 command, you delete file `/usr/doc/old' and create directory
4903 `/usr/local/db' with the following contents:
4904
4905      $ ls /usr/local/db
4906      /usr/local/db/data
4907      /usr/local/db/index
4908
4909    Some time later you create another incremental backup.  You will
4910 then see:
4911
4912      $ tar --create \
4913                 --file=archive.2.tar \
4914                 --listed-incremental=/var/log/usr.snar \
4915                 /usr
4916      tar: usr/local/db: Directory is new
4917      usr/local/db/
4918      usr/local/db/data
4919      usr/local/db/index
4920
4921 The created archive `archive.2.tar' will contain only these three
4922 members.  This archive is called a "level 1 backup".  Notice that
4923 `/var/log/usr.snar' will be updated with the new data, so if you plan
4924 to create more `level 1' backups, it is necessary to create a working
4925 copy of the snapshot file before running `tar'.  The above example will
4926 then be modified as follows:
4927
4928      $ cp /var/log/usr.snar /var/log/usr.snar-1
4929      $ tar --create \
4930                 --file=archive.2.tar \
4931                 --listed-incremental=/var/log/usr.snar-1 \
4932                 /usr
4933
4934    Incremental dumps depend crucially on time stamps, so the results are
4935 unreliable if you modify a file's time stamps during dumping (e.g.,
4936 with the `--atime-preserve=replace' option), or if you set the clock
4937 backwards.
4938
4939    Metadata stored in snapshot files include device numbers, which,
4940 obviously are supposed to be a non-volatile values.  However, it turns
4941 out that NFS devices have undependable values when an automounter gets
4942 in the picture.  This can lead to a great deal of spurious redumping in
4943 incremental dumps, so it is somewhat useless to compare two NFS devices
4944 numbers over time.  The solution implemented currently is to considers
4945 all NFS devices as being equal when it comes to comparing directories;
4946 this is fairly gross, but there does not seem to be a better way to go.
4947
4948    Apart from using NFS, there are a number of cases where relying on
4949 device numbers can cause spurious redumping of unmodified files.  For
4950 example, this occurs when archiving LVM snapshot volumes.  To avoid
4951 this, use `--no-check-device' option:
4952
4953 `--no-check-device'
4954      Do not rely on device numbers when preparing a list of changed
4955      files for an incremental dump.
4956
4957 `--check-device'
4958      Use device numbers when preparing a list of changed files for an
4959      incremental dump.  This is the default behavior.  The purpose of
4960      this option is to undo the effect of the `--no-check-device' if it
4961      was given in `TAR_OPTIONS' environment variable (*note
4962      TAR_OPTIONS::).
4963
4964    There is also another way to cope with changing device numbers.  It
4965 is described in detail in *note Fixing Snapshot Files::.
4966
4967    Note that incremental archives use `tar' extensions and may not be
4968 readable by non-GNU versions of the `tar' program.
4969
4970    To extract from the incremental dumps, use `--listed-incremental'
4971 together with `--extract' option (*note extracting files::).  In this
4972 case, `tar' does not need to access snapshot file, since all the data
4973 necessary for extraction are stored in the archive itself.  So, when
4974 extracting, you can give whatever argument to `--listed-incremental',
4975 the usual practice is to use `--listed-incremental=/dev/null'.
4976 Alternatively, you can use `--incremental', which needs no arguments.
4977 In general, `--incremental' (`-G') can be used as a shortcut for
4978 `--listed-incremental' when listing or extracting incremental backups
4979 (for more information, regarding this option, *note incremental-op::).
4980
4981    When extracting from the incremental backup GNU `tar' attempts to
4982 restore the exact state the file system had when the archive was
4983 created.  In particular, it will _delete_ those files in the file
4984 system that did not exist in their directories when the archive was
4985 created.  If you have created several levels of incremental files, then
4986 in order to restore the exact contents the file system  had when the
4987 last level was created, you will need to restore from all backups in
4988 turn.  Continuing our example, to restore the state of `/usr' file
4989 system, one would do(1):
4990
4991      $ tar --extract \
4992                 --listed-incremental=/dev/null \
4993                 --file archive.1.tar
4994      $ tar --extract \
4995                 --listed-incremental=/dev/null \
4996                 --file archive.2.tar
4997
4998    To list the contents of an incremental archive, use `--list' (*note
4999 list::), as usual.  To obtain more information about the archive, use
5000 `--listed-incremental' or `--incremental' combined with two `--verbose'
5001 options(2):
5002
5003      tar --list --incremental --verbose --verbose archive.tar
5004
5005    This command will print, for each directory in the archive, the list
5006 of files in that directory at the time the archive was created.  This
5007 information is put out in a format which is both human-readable and
5008 unambiguous for a program: each file name is printed as
5009
5010      X FILE
5011
5012 where X is a letter describing the status of the file: `Y' if the file
5013 is present in the archive, `N' if the file is not included in the
5014 archive, or a `D' if the file is a directory (and is included in the
5015 archive).  *Note Dumpdir::, for the detailed description of dumpdirs
5016 and status codes.  Each such line is terminated by a newline character.
5017 The last line is followed by an additional newline to indicate the end
5018 of the data.
5019
5020    The option `--incremental' (`-G') gives the same behavior as
5021 `--listed-incremental' when used with `--list' and `--extract' options.
5022 When used with `--create' option, it creates an incremental archive
5023 without creating snapshot file.  Thus, it is impossible to create
5024 several levels of incremental backups with `--incremental' option.
5025
5026    ---------- Footnotes ----------
5027
5028    (1) Notice, that since both archives were created without `-P'
5029 option (*note absolute::), these commands should be run from the root
5030 file system.
5031
5032    (2) Two `--verbose' options were selected to avoid breaking usual
5033 verbose listing output (`--list --verbose') when using in scripts.
5034
5035    Versions of GNU `tar' up to 1.15.1 used to dump verbatim binary
5036 contents of the DUMPDIR header (with terminating nulls) when
5037 `--incremental' or `--listed-incremental' option was given, no matter
5038 what the verbosity level.  This behavior, and, especially, the binary
5039 output it produced were considered inconvenient and were changed in
5040 version 1.16
5041
5042 \1f
5043 File: tar.info,  Node: Backup Levels,  Next: Backup Parameters,  Prev: Incremental Dumps,  Up: Backups
5044
5045 5.3 Levels of Backups
5046 =====================
5047
5048 An archive containing all the files in the file system is called a
5049 "full backup" or "full dump".  You could insure your data by creating a
5050 full dump every day.  This strategy, however, would waste a substantial
5051 amount of archive media and user time, as unchanged files are daily
5052 re-archived.
5053
5054    It is more efficient to do a full dump only occasionally.  To back up
5055 files between full dumps, you can use "incremental dumps".  A "level
5056 one" dump archives all the files that have changed since the last full
5057 dump.
5058
5059    A typical dump strategy would be to perform a full dump once a week,
5060 and a level one dump once a day.  This means some versions of files
5061 will in fact be archived more than once, but this dump strategy makes
5062 it possible to restore a file system to within one day of accuracy by
5063 only extracting two archives--the last weekly (full) dump and the last
5064 daily (level one) dump.  The only information lost would be in files
5065 changed or created since the last daily backup.  (Doing dumps more than
5066 once a day is usually not worth the trouble).
5067
5068    GNU `tar' comes with scripts you can use to do full and level-one
5069 (actually, even level-two and so on) dumps.  Using scripts (shell
5070 programs) to perform backups and restoration is a convenient and
5071 reliable alternative to typing out file name lists and `tar' commands
5072 by hand.
5073
5074    Before you use these scripts, you need to edit the file
5075 `backup-specs', which specifies parameters used by the backup scripts
5076 and by the restore script.  This file is usually located in
5077 `/etc/backup' directory.  *Note Backup Parameters::, for its detailed
5078 description.  Once the backup parameters are set, you can perform
5079 backups or restoration by running the appropriate script.
5080
5081    The name of the backup script is `backup'.  The name of the restore
5082 script is `restore'.  The following sections describe their use in
5083 detail.
5084
5085    _Please Note:_ The backup and restoration scripts are designed to be
5086 used together.  While it is possible to restore files by hand from an
5087 archive which was created using a backup script, and to create an
5088 archive by hand which could then be extracted using the restore script,
5089 it is easier to use the scripts.  *Note Incremental Dumps::, before
5090 making such an attempt.
5091
5092 \1f
5093 File: tar.info,  Node: Backup Parameters,  Next: Scripted Backups,  Prev: Backup Levels,  Up: Backups
5094
5095 5.4 Setting Parameters for Backups and Restoration
5096 ==================================================
5097
5098 The file `backup-specs' specifies backup parameters for the backup and
5099 restoration scripts provided with `tar'.  You must edit `backup-specs'
5100 to fit your system configuration and schedule before using these
5101 scripts.
5102
5103    Syntactically, `backup-specs' is a shell script, containing mainly
5104 variable assignments.  However, any valid shell construct is allowed in
5105 this file.  Particularly, you may wish to define functions within that
5106 script (e.g., see `RESTORE_BEGIN' below).  For more information about
5107 shell script syntax, please refer to the definition of the Shell
5108 Command Language
5109 (http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
5110 g_02).  See also *note Bash Features: (bashref)Top.
5111
5112    The shell variables controlling behavior of `backup' and `restore'
5113 are described in the following subsections.
5114
5115 * Menu:
5116
5117 * General-Purpose Variables::
5118 * Magnetic Tape Control::
5119 * User Hooks::
5120 * backup-specs example::        An Example Text of `Backup-specs'
5121
5122 \1f
5123 File: tar.info,  Node: General-Purpose Variables,  Next: Magnetic Tape Control,  Up: Backup Parameters
5124
5125 5.4.1 General-Purpose Variables
5126 -------------------------------
5127
5128  -- Backup variable: ADMINISTRATOR
5129      The user name of the backup administrator.  `Backup' scripts sends
5130      a backup report to this address.
5131
5132  -- Backup variable: BACKUP_HOUR
5133      The hour at which the backups are done.  This can be a number from
5134      0 to 23, or the time specification in form HOURS:MINUTES, or the
5135      string `now'.
5136
5137      This variable is used by `backup'.  Its value may be overridden
5138      using `--time' option (*note Scripted Backups::).
5139
5140  -- Backup variable: TAPE_FILE
5141      The device `tar' writes the archive to.  If TAPE_FILE is a remote
5142      archive (*note remote-dev::), backup script will suppose that your
5143      `mt' is able to access remote devices.  If RSH (*note RSH::) is
5144      set, `--rsh-command' option will be added to invocations of `mt'.
5145
5146  -- Backup variable: BLOCKING
5147      The blocking factor `tar' will use when writing the dump archive.
5148      *Note Blocking Factor::.
5149
5150  -- Backup variable: BACKUP_DIRS
5151      A list of file systems to be dumped (for `backup'), or restored
5152      (for `restore').  You can include any directory name in the list
5153      -- subdirectories on that file system will be included, regardless
5154      of how they may look to other networked machines.  Subdirectories
5155      on other file systems will be ignored.
5156
5157      The host name specifies which host to run `tar' on, and should
5158      normally be the host that actually contains the file system.
5159      However, the host machine must have GNU `tar' installed, and must
5160      be able to access the directory containing the backup scripts and
5161      their support files using the same file name that is used on the
5162      machine where the scripts are run (i.e., what `pwd' will print
5163      when in that directory on that machine).  If the host that contains
5164      the file system does not have this capability, you can specify
5165      another host as long as it can access the file system through NFS.
5166
5167      If the list of file systems is very long you may wish to put it in
5168      a separate file.  This file is usually named `/etc/backup/dirs',
5169      but this name may be overridden in `backup-specs' using `DIRLIST'
5170      variable.
5171
5172  -- Backup variable: DIRLIST
5173      The name of the file that contains a list of file systems to backup
5174      or restore.  By default it is `/etc/backup/dirs'.
5175
5176  -- Backup variable: BACKUP_FILES
5177      A list of individual files to be dumped (for `backup'), or restored
5178      (for `restore').  These should be accessible from the machine on
5179      which the backup script is run.
5180
5181      If the list of file systems is very long you may wish to store it
5182      in a separate file.  This file is usually named
5183      `/etc/backup/files', but this name may be overridden in
5184      `backup-specs' using `FILELIST' variable.
5185
5186  -- Backup variable: FILELIST
5187      The name of the file that contains a list of individual files to
5188      backup or restore.  By default it is `/etc/backup/files'.
5189
5190  -- Backup variable: MT
5191      Full file name of `mt' binary.
5192
5193  -- Backup variable: RSH
5194      Full file name of `rsh' binary or its equivalent.  You may wish to
5195      set it to `ssh', to improve security.  In this case you will have
5196      to use public key authentication.
5197
5198  -- Backup variable: RSH_COMMAND
5199      Full file name of `rsh' binary on remote machines.  This will be
5200      passed via `--rsh-command' option to the remote invocation of GNU
5201      `tar'.
5202
5203  -- Backup variable: VOLNO_FILE
5204      Name of temporary file to hold volume numbers.  This needs to be
5205      accessible by all the machines which have file systems to be
5206      dumped.
5207
5208  -- Backup variable: XLIST
5209      Name of "exclude file list".  An "exclude file list" is a file
5210      located on the remote machine and containing the list of files to
5211      be excluded from the backup.  Exclude file lists are searched in
5212      /etc/tar-backup directory.  A common use for exclude file lists is
5213      to exclude files containing security-sensitive information (e.g.,
5214      `/etc/shadow' from backups).
5215
5216      This variable affects only `backup'.
5217
5218  -- Backup variable: SLEEP_TIME
5219      Time to sleep between dumps of any two successive file systems
5220
5221      This variable affects only `backup'.
5222
5223  -- Backup variable: DUMP_REMIND_SCRIPT
5224      Script to be run when it's time to insert a new tape in for the
5225      next volume.  Administrators may want to tailor this script for
5226      their site.  If this variable isn't set, GNU `tar' will display
5227      its built-in prompt, and will expect confirmation from the
5228      console.  For the description of the default prompt, see *note
5229      change volume prompt::.
5230
5231
5232  -- Backup variable: SLEEP_MESSAGE
5233      Message to display on the terminal while waiting for dump time.
5234      Usually this will just be some literal text.
5235
5236  -- Backup variable: TAR
5237      Full file name of the GNU `tar' executable.  If this is not set,
5238      backup scripts will search `tar' in the current shell path.
5239
5240 \1f
5241 File: tar.info,  Node: Magnetic Tape Control,  Next: User Hooks,  Prev: General-Purpose Variables,  Up: Backup Parameters
5242
5243 5.4.2 Magnetic Tape Control
5244 ---------------------------
5245
5246 Backup scripts access tape device using special "hook functions".
5247 These functions take a single argument - the name of the tape device.
5248 Their names are kept in the following variables:
5249
5250  -- Backup variable: MT_BEGIN
5251      The name of "begin" function.  This function is called before
5252      accessing the drive.  By default it retensions the tape:
5253
5254           MT_BEGIN=mt_begin
5255
5256           mt_begin() {
5257               mt -f "$1" retension
5258           }
5259
5260  -- Backup variable: MT_REWIND
5261      The name of "rewind" function.  The default definition is as
5262      follows:
5263
5264           MT_REWIND=mt_rewind
5265
5266           mt_rewind() {
5267               mt -f "$1" rewind
5268           }
5269
5270
5271  -- Backup variable: MT_OFFLINE
5272      The name of the function switching the tape off line.  By default
5273      it is defined as follows:
5274
5275           MT_OFFLINE=mt_offline
5276
5277           mt_offline() {
5278               mt -f "$1" offl
5279           }
5280
5281  -- Backup variable: MT_STATUS
5282      The name of the function used to obtain the status of the archive
5283      device, including error count.  Default definition:
5284
5285           MT_STATUS=mt_status
5286
5287           mt_status() {
5288               mt -f "$1" status
5289           }
5290
5291 \1f
5292 File: tar.info,  Node: User Hooks,  Next: backup-specs example,  Prev: Magnetic Tape Control,  Up: Backup Parameters
5293
5294 5.4.3 User Hooks
5295 ----------------
5296
5297 "User hooks" are shell functions executed before and after each `tar'
5298 invocation.  Thus, there are "backup hooks", which are executed before
5299 and after dumping each file system, and "restore hooks", executed
5300 before and after restoring a file system.  Each user hook is a shell
5301 function taking four arguments:
5302
5303  -- User Hook Function: hook LEVEL HOST FS FSNAME
5304      Its arguments are:
5305
5306     LEVEL
5307           Current backup or restore level.
5308
5309     HOST
5310           Name or IP address of the host machine being dumped or
5311           restored.
5312
5313     FS
5314           Full file name of the file system being dumped or restored.
5315
5316     FSNAME
5317           File system name with directory separators replaced with
5318           colons.  This is useful, e.g., for creating unique files.
5319
5320    Following variables keep the names of user hook functions
5321
5322  -- Backup variable: DUMP_BEGIN
5323      Dump begin function.  It is executed before dumping the file
5324      system.
5325
5326  -- Backup variable: DUMP_END
5327      Executed after dumping the file system.
5328
5329  -- Backup variable: RESTORE_BEGIN
5330      Executed before restoring the file system.
5331
5332  -- Backup variable: RESTORE_END
5333      Executed after restoring the file system.
5334
5335 \1f
5336 File: tar.info,  Node: backup-specs example,  Prev: User Hooks,  Up: Backup Parameters
5337
5338 5.4.4 An Example Text of `Backup-specs'
5339 ---------------------------------------
5340
5341 The following is an example of `backup-specs':
5342
5343      # site-specific parameters for file system backup.
5344
5345      ADMINISTRATOR=friedman
5346      BACKUP_HOUR=1
5347      TAPE_FILE=/dev/nrsmt0
5348
5349      # Use `ssh' instead of the less secure `rsh'
5350      RSH=/usr/bin/ssh
5351      RSH_COMMAND=/usr/bin/ssh
5352
5353      # Override MT_STATUS function:
5354      my_status() {
5355            mts -t $TAPE_FILE
5356      }
5357      MT_STATUS=my_status
5358
5359      # Disable MT_OFFLINE function
5360      MT_OFFLINE=:
5361
5362      BLOCKING=124
5363      BACKUP_DIRS="
5364              albert:/fs/fsf
5365              apple-gunkies:/gd
5366              albert:/fs/gd2
5367              albert:/fs/gp
5368              geech:/usr/jla
5369              churchy:/usr/roland
5370              albert:/
5371              albert:/usr
5372              apple-gunkies:/
5373              apple-gunkies:/usr
5374              gnu:/hack
5375              gnu:/u
5376              apple-gunkies:/com/mailer/gnu
5377              apple-gunkies:/com/archive/gnu"
5378
5379      BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
5380
5381 \1f
5382 File: tar.info,  Node: Scripted Backups,  Next: Scripted Restoration,  Prev: Backup Parameters,  Up: Backups
5383
5384 5.5 Using the Backup Scripts
5385 ============================
5386
5387 The syntax for running a backup script is:
5388
5389      backup --level=LEVEL --time=TIME
5390
5391    The `level' option requests the dump level.  Thus, to produce a full
5392 dump, specify `--level=0' (this is the default, so `--level' may be
5393 omitted if its value is `0').  (1)
5394
5395    The `--time' option determines when should the backup be run.  TIME
5396 may take three forms:
5397
5398 HH:MM
5399      The dump must be run at HH hours MM minutes.
5400
5401 HH
5402      The dump must be run at HH hours
5403
5404 now
5405      The dump must be run immediately.
5406
5407    You should start a script with a tape or disk mounted.  Once you
5408 start a script, it prompts you for new tapes or disks as it needs them.
5409 Media volumes don't have to correspond to archive files -- a
5410 multi-volume archive can be started in the middle of a tape that
5411 already contains the end of another multi-volume archive.  The
5412 `restore' script prompts for media by its archive volume, so to avoid
5413 an error message you should keep track of which tape (or disk) contains
5414 which volume of the archive (*note Scripted Restoration::).
5415
5416    The backup scripts write two files on the file system.  The first is
5417 a record file in `/etc/tar-backup/', which is used by the scripts to
5418 store and retrieve information about which files were dumped.  This
5419 file is not meant to be read by humans, and should not be deleted by
5420 them.  *Note Snapshot Files::, for a more detailed explanation of this
5421 file.
5422
5423    The second file is a log file containing the names of the file
5424 systems and files dumped, what time the backup was made, and any error
5425 messages that were generated, as well as how much space was left in the
5426 media volume after the last volume of the archive was written.  You
5427 should check this log file after every backup.  The file name is
5428 `log-MM-DD-YYYY-level-N', where MM-DD-YYYY represents current date, and
5429 N represents current dump level number.
5430
5431    The script also prints the name of each system being dumped to the
5432 standard output.
5433
5434    Following is the full list of options accepted by `backup' script:
5435
5436 `-l LEVEL'
5437 `--level=LEVEL'
5438      Do backup level LEVEL (default 0).
5439
5440 `-f'
5441 `--force'
5442      Force backup even if today's log file already exists.
5443
5444 `-v[LEVEL]'
5445 `--verbose[=LEVEL]'
5446      Set verbosity level.  The higher the level is, the more debugging
5447      information will be output during execution.  Default LEVEL is
5448      100, which means the highest debugging level.
5449
5450 `-t START-TIME'
5451 `--time=START-TIME'
5452      Wait till TIME, then do backup.
5453
5454 `-h'
5455 `--help'
5456      Display short help message and exit.
5457
5458 `-V'
5459 `--version'
5460      Display information about the program's name, version, origin and
5461      legal status, all on standard output, and then exit successfully.
5462
5463    ---------- Footnotes ----------
5464
5465    (1) For backward compatibility, the `backup' will also try to deduce
5466 the requested dump level from the name of the script itself.  If the
5467 name consists of a string `level-' followed by a single decimal digit,
5468 that digit is taken as the dump level number.  Thus, you may create a
5469 link from `backup' to `level-1' and then run `level-1' whenever you
5470 need to create a level one dump.
5471
5472 \1f
5473 File: tar.info,  Node: Scripted Restoration,  Prev: Scripted Backups,  Up: Backups
5474
5475 5.6 Using the Restore Script
5476 ============================
5477
5478 To restore files that were archived using a scripted backup, use the
5479 `restore' script.  Its usage is quite straightforward.  In the simplest
5480 form, invoke `restore --all', it will then restore all the file systems
5481 and files specified in `backup-specs' (*note BACKUP_DIRS:
5482 General-Purpose Variables.).
5483
5484    You may select the file systems (and/or files) to restore by giving
5485 `restore' list of "patterns" in its command line.  For example, running
5486
5487      restore 'albert:*'
5488
5489 will restore all file systems on the machine `albert'.  A more
5490 complicated example:
5491
5492      restore 'albert:*' '*:/var'
5493
5494 This command will restore all file systems on the machine `albert' as
5495 well as `/var' file system on all machines.
5496
5497    By default `restore' will start restoring files from the lowest
5498 available dump level (usually zero) and will continue through all
5499 available dump levels.  There may be situations where such a thorough
5500 restore is not necessary.  For example, you may wish to restore only
5501 files from the recent level one backup.  To do so, use `--level'
5502 option, as shown in the example below:
5503
5504      restore --level=1
5505
5506    The full list of options accepted by `restore' follows:
5507
5508 `-a'
5509 `--all'
5510      Restore all file systems and files specified in `backup-specs'
5511
5512 `-l LEVEL'
5513 `--level=LEVEL'
5514      Start restoring from the given backup level, instead of the
5515      default 0.
5516
5517 `-v[LEVEL]'
5518 `--verbose[=LEVEL]'
5519      Set verbosity level.  The higher the level is, the more debugging
5520      information will be output during execution.  Default LEVEL is
5521      100, which means the highest debugging level.
5522
5523 `-h'
5524 `--help'
5525      Display short help message and exit.
5526
5527 `-V'
5528 `--version'
5529      Display information about the program's name, version, origin and
5530      legal status, all on standard output, and then exit successfully.
5531
5532    You should start the restore script with the media containing the
5533 first volume of the archive mounted.  The script will prompt for other
5534 volumes as they are needed.  If the archive is on tape, you don't need
5535 to rewind the tape to to its beginning--if the tape head is positioned
5536 past the beginning of the archive, the script will rewind the tape as
5537 needed.  *Note Tape Positioning::, for a discussion of tape positioning.
5538
5539      *Warning:* The script will delete files from the active file
5540      system if they were not in the file system when the archive was
5541      made.
5542
5543    *Note Incremental Dumps::, for an explanation of how the script makes
5544 that determination.
5545
5546 \1f
5547 File: tar.info,  Node: Choosing,  Next: Date input formats,  Prev: Backups,  Up: Top
5548
5549 6 Choosing Files and Names for `tar'
5550 ************************************
5551
5552      _(This message will disappear, once this node revised.)_
5553
5554 Certain options to `tar' enable you to specify a name for your archive.
5555 Other options let you decide which files to include or exclude from the
5556 archive, based on when or whether files were modified, whether the file
5557 names do or don't match specified patterns, or whether files are in
5558 specified directories.
5559
5560    This chapter discusses these options in detail.
5561
5562 * Menu:
5563
5564 * file::                        Choosing the Archive's Name
5565 * Selecting Archive Members::
5566 * files::                       Reading Names from a File
5567 * exclude::                     Excluding Some Files
5568 * wildcards::                   Wildcards Patterns and Matching
5569 * quoting styles::              Ways of Quoting Special Characters in Names
5570 * transform::                   Modifying File and Member Names
5571 * after::                       Operating Only on New Files
5572 * recurse::                     Descending into Directories
5573 * one::                         Crossing File System Boundaries
5574
5575 \1f
5576 File: tar.info,  Node: file,  Next: Selecting Archive Members,  Up: Choosing
5577
5578 6.1 Choosing and Naming Archive Files
5579 =====================================
5580
5581      _(This message will disappear, once this node revised.)_
5582
5583 By default, `tar' uses an archive file name that was compiled when it
5584 was built on the system; usually this name refers to some physical tape
5585 drive on the machine.  However, the person who installed `tar' on the
5586 system may not have set the default to a meaningful value as far as
5587 most users are concerned.  As a result, you will usually want to tell
5588 `tar' where to find (or create) the archive.  The `--file=ARCHIVE-NAME'
5589 (`-f ARCHIVE-NAME') option allows you to either specify or name a file
5590 to use as the archive instead of the default archive file location.
5591
5592 `--file=ARCHIVE-NAME'
5593 `-f ARCHIVE-NAME'
5594      Name the archive to create or operate on.  Use in conjunction with
5595      any operation.
5596
5597    For example, in this `tar' command,
5598
5599      $ tar -cvf collection.tar blues folk jazz
5600
5601 `collection.tar' is the name of the archive.  It must directly follow
5602 the `-f' option, since whatever directly follows `-f' _will_ end up
5603 naming the archive.  If you neglect to specify an archive name, you may
5604 end up overwriting a file in the working directory with the archive you
5605 create since `tar' will use this file's name for the archive name.
5606
5607    An archive can be saved as a file in the file system, sent through a
5608 pipe or over a network, or written to an I/O device such as a tape,
5609 floppy disk, or CD write drive.
5610
5611    If you do not name the archive, `tar' uses the value of the
5612 environment variable `TAPE' as the file name for the archive.  If that
5613 is not available, `tar' uses a default, compiled-in archive name,
5614 usually that for tape unit zero (i.e., `/dev/tu00').
5615
5616    If you use `-' as an ARCHIVE-NAME, `tar' reads the archive from
5617 standard input (when listing or extracting files), or writes it to
5618 standard output (when creating an archive).  If you use `-' as an
5619 ARCHIVE-NAME when modifying an archive, `tar' reads the original
5620 archive from its standard input and writes the entire new archive to
5621 its standard output.
5622
5623    The following example is a convenient way of copying directory
5624 hierarchy from `sourcedir' to `targetdir'.
5625
5626      $ (cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)
5627
5628    The `-C' option allows to avoid using subshells:
5629
5630      $ tar -C sourcedir -cf - . | tar -C targetdir -xpf -
5631
5632    In both examples above, the leftmost `tar' invocation archives the
5633 contents of `sourcedir' to the standard output, while the rightmost one
5634 reads this archive from its standard input and extracts it.  The `-p'
5635 option tells it to restore permissions of the extracted files.
5636
5637    To specify an archive file on a device attached to a remote machine,
5638 use the following:
5639
5640      --file=HOSTNAME:/DEV/FILE-NAME
5641
5642 `tar' will complete the remote connection, if possible, and prompt you
5643 for a username and password.  If you use
5644 `--file=@HOSTNAME:/DEV/FILE-NAME', `tar' will complete the remote
5645 connection, if possible, using your username as the username on the
5646 remote machine.
5647
5648    If the archive file name includes a colon (`:'), then it is assumed
5649 to be a file on another machine.  If the archive file is
5650 `USER@HOST:FILE', then FILE is used on the host HOST.  The remote host
5651 is accessed using the `rsh' program, with a username of USER.  If the
5652 username is omitted (along with the `@' sign), then your user name will
5653 be used.  (This is the normal `rsh' behavior.)  It is necessary for the
5654 remote machine, in addition to permitting your `rsh' access, to have
5655 the `rmt' program installed (This command is included in the GNU `tar'
5656 distribution and by default is installed under `PREFIX/libexec/rmt',
5657 were PREFIX means your installation prefix).  If you need to use a file
5658 whose name includes a colon, then the remote tape drive behavior can be
5659 inhibited by using the `--force-local' option.
5660
5661    When the archive is being created to `/dev/null', GNU `tar' tries to
5662 minimize input and output operations.  The Amanda backup system, when
5663 used with GNU `tar', has an initial sizing pass which uses this feature.
5664
5665 \1f
5666 File: tar.info,  Node: Selecting Archive Members,  Next: files,  Prev: file,  Up: Choosing
5667
5668 6.2 Selecting Archive Members
5669 =============================
5670
5671 "File Name arguments" specify which files in the file system `tar'
5672 operates on, when creating or adding to an archive, or which archive
5673 members `tar' operates on, when reading or deleting from an archive.
5674 *Note Operations::.
5675
5676    To specify file names, you can include them as the last arguments on
5677 the command line, as follows:
5678      tar OPERATION [OPTION1 OPTION2 ...] [FILE NAME-1 FILE NAME-2 ...]
5679
5680    If a file name begins with dash (`-'), precede it with `--add-file'
5681 option to prevent it from being treated as an option.
5682
5683    By default GNU `tar' attempts to "unquote" each file or member name,
5684 replacing "escape sequences" according to the following table:
5685
5686 Escape         Replaced with
5687 ----------------------------------------------------------- 
5688 \a             Audible bell (ASCII 7)
5689 \b             Backspace (ASCII 8)
5690 \f             Form feed (ASCII 12)
5691 \n             New line (ASCII 10)
5692 \r             Carriage return (ASCII 13)
5693 \t             Horizontal tabulation (ASCII 9)
5694 \v             Vertical tabulation (ASCII 11)
5695 \?             ASCII 127
5696 \N             ASCII N (N should be an octal number
5697                          of up to 3 digits)
5698
5699    A backslash followed by any other symbol is retained.
5700
5701    This default behavior is controlled by the following command line
5702 option:
5703
5704 `--unquote'
5705      Enable unquoting input file or member names (default).
5706
5707 `--no-unquote'
5708      Disable unquoting input file or member names.
5709
5710    If you specify a directory name as a file name argument, all the
5711 files in that directory are operated on by `tar'.
5712
5713    If you do not specify files, `tar' behavior differs depending on the
5714 operation mode as described below:
5715
5716    When `tar' is invoked with `--create' (`-c'), `tar' will stop
5717 immediately, reporting the following:
5718
5719      $ tar cf a.tar
5720      tar: Cowardly refusing to create an empty archive
5721      Try `tar --help' or `tar --usage' for more information.
5722
5723    If you specify either `--list' (`-t') or `--extract' (`--get',
5724 `-x'), `tar' operates on all the archive members in the archive.
5725
5726    If run with `--diff' option, tar will compare the archive with the
5727 contents of the current working directory.
5728
5729    If you specify any other operation, `tar' does nothing.
5730
5731    By default, `tar' takes file names from the command line.  However,
5732 there are other ways to specify file or member names, or to modify the
5733 manner in which `tar' selects the files or members upon which to
5734 operate.  In general, these methods work both for specifying the names
5735 of files and archive members.
5736
5737 \1f
5738 File: tar.info,  Node: files,  Next: exclude,  Prev: Selecting Archive Members,  Up: Choosing
5739
5740 6.3 Reading Names from a File
5741 =============================
5742
5743 Instead of giving the names of files or archive members on the command
5744 line, you can put the names into a file, and then use the
5745 `--files-from=FILE-OF-NAMES' (`-T FILE-OF-NAMES') option to `tar'.
5746 Give the name of the file which contains the list of files to include
5747 as the argument to `--files-from'.  In the list, the file names should
5748 be separated by newlines.  You will frequently use this option when you
5749 have generated the list of files to archive with the `find' utility.
5750
5751 `--files-from=FILE-NAME'
5752 `-T FILE-NAME'
5753      Get names to extract or create from file FILE-NAME.
5754
5755    If you give a single dash as a file name for `--files-from', (i.e.,
5756 you specify either `--files-from=-' or `-T -'), then the file names are
5757 read from standard input.
5758
5759    Unless you are running `tar' with `--create', you can not use both
5760 `--files-from=-' and `--file=-' (`-f -') in the same command.
5761
5762    Any number of `-T' options can be given in the command line.
5763
5764    The following example shows how to use `find' to generate a list of
5765 files smaller than 400K in length and put that list into a file called
5766 `small-files'.  You can then use the `-T' option to `tar' to specify
5767 the files from that file, `small-files', to create the archive
5768 `little.tgz'.  (The `-z' option to `tar' compresses the archive with
5769 `gzip'; *note gzip:: for more information.)
5770
5771      $ find .  -size -400 -print > small-files
5772      $ tar -c -v -z -T small-files -f little.tgz
5773
5774 In the file list given by `-T' option, any file name beginning with `-'
5775 character is considered a `tar' option and is processed accordingly.(1)
5776 For example, the common use of this feature is to change to another
5777 directory by specifying `-C' option:
5778
5779      $ cat list
5780      -C/etc
5781      passwd
5782      hosts
5783      -C/lib
5784      libc.a
5785      $ tar -c -f foo.tar --files-from list
5786
5787 In this example, `tar' will first switch to `/etc' directory and add
5788 files `passwd' and `hosts' to the archive.  Then it will change to
5789 `/lib' directory and will archive the file `libc.a'.  Thus, the
5790 resulting archive `foo.tar' will contain:
5791
5792      $ tar tf foo.tar
5793      passwd
5794      hosts
5795      libc.a
5796
5797
5798    Notice that the option parsing algorithm used with `-T' is stricter
5799 than the one used by shell.  Namely, when specifying option arguments,
5800 you should observe the following rules:
5801
5802    * When using short (single-letter) option form, its argument must
5803      immediately follow the option letter, without any intervening
5804      whitespace.  For example: `-Cdir'.
5805
5806    * When using long option form, the option argument must be separated
5807      from the option by a single equal sign.  No whitespace is allowed
5808      on any side of the equal sign.  For example: `--directory=dir'.
5809
5810    * For both short and long option forms, the option argument can be
5811      given on the next line after the option name, e.g.:
5812
5813           --directory
5814           dir
5815
5816      and
5817
5818           -C
5819           dir
5820
5821    If you happen to have a file whose name starts with `-', precede it
5822 with `--add-file' option to prevent it from being recognized as an
5823 option.  For example: `--add-file=--my-file'.
5824
5825 * Menu:
5826
5827 * nul::
5828
5829    ---------- Footnotes ----------
5830
5831    (1) Versions of GNU `tar' up to 1.15.1 recognized only `-C' option
5832 in file lists, and only if the option and its argument occupied two
5833 consecutive lines.
5834
5835 \1f
5836 File: tar.info,  Node: nul,  Up: files
5837
5838 6.3.1 `NUL' Terminated File Names
5839 ---------------------------------
5840
5841 The `--null' option causes `--files-from=FILE-OF-NAMES' (`-T
5842 FILE-OF-NAMES') to read file names terminated by a `NUL' instead of a
5843 newline, so files whose names contain newlines can be archived using
5844 `--files-from'.
5845
5846 `--null'
5847      Only consider `NUL' terminated file names, instead of files that
5848      terminate in a newline.
5849
5850 `--no-null'
5851      Undo the effect of any previous `--null' option.
5852
5853    The `--null' option is just like the one in GNU `xargs' and `cpio',
5854 and is useful with the `-print0' predicate of GNU `find'.  In `tar',
5855 `--null' also disables special handling for file names that begin with
5856 dash.
5857
5858    This example shows how to use `find' to generate a list of files
5859 larger than 800K in length and put that list into a file called
5860 `long-files'.  The `-print0' option to `find' is just like `-print',
5861 except that it separates files with a `NUL' rather than with a newline.
5862 You can then run `tar' with both the `--null' and `-T' options to
5863 specify that `tar' get the files from that file, `long-files', to
5864 create the archive `big.tgz'.  The `--null' option to `tar' will cause
5865 `tar' to recognize the `NUL' separator between files.
5866
5867      $ find .  -size +800 -print0 > long-files
5868      $ tar -c -v --null --files-from=long-files --file=big.tar
5869
5870    The `--no-null' option can be used if you need to read both
5871 zero-terminated and newline-terminated files on the same command line.
5872 For example, if `flist' is a newline-terminated file, then the
5873 following command can be used to combine it with the above command:
5874
5875      $ find .  -size +800 -print0 |
5876        tar -c -f big.tar --null -T - --no-null -T flist
5877
5878    This example uses short options for typographic reasons, to avoid
5879 very long lines.
5880
5881    GNU `tar' is able to automatically detect null-terminated file
5882 lists, so it is safe to use them even without the `--null' option.  In
5883 this case `tar' will print a warning and continue reading such a file
5884 as if `--null' were actually given:
5885
5886      $ find .  -size +800 -print0 | tar -c -f big.tar -T -
5887      tar: -: file name read contains nul character
5888
5889    The null terminator, however, remains in effect only for this
5890 particular file, any following `-T' options will assume newline
5891 termination.  Of course, the null autodetection applies to these
5892 eventual surplus `-T' options as well.
5893
5894 \1f
5895 File: tar.info,  Node: exclude,  Next: wildcards,  Prev: files,  Up: Choosing
5896
5897 6.4 Excluding Some Files
5898 ========================
5899
5900      _(This message will disappear, once this node revised.)_
5901
5902 To avoid operating on files whose names match a particular pattern, use
5903 the `--exclude' or `--exclude-from' options.
5904
5905 `--exclude=PATTERN'
5906      Causes `tar' to ignore files that match the PATTERN.
5907
5908    The `--exclude=PATTERN' option prevents any file or member whose
5909 name matches the shell wildcard (PATTERN) from being operated on.  For
5910 example, to create an archive with all the contents of the directory
5911 `src' except for files whose names end in `.o', use the command `tar
5912 -cf src.tar --exclude='*.o' src'.
5913
5914    You may give multiple `--exclude' options.
5915
5916 `--exclude-from=FILE'
5917 `-X FILE'
5918      Causes `tar' to ignore files that match the patterns listed in
5919      FILE.
5920
5921    Use the `--exclude-from' option to read a list of patterns, one per
5922 line, from FILE; `tar' will ignore files matching those patterns.  Thus
5923 if `tar' is called as `tar -c -X foo .' and the file `foo' contains a
5924 single line `*.o', no files whose names end in `.o' will be added to
5925 the archive.
5926
5927    Notice, that lines from FILE are read verbatim. One of the frequent
5928 errors is leaving some extra whitespace after a file name, which is
5929 difficult to catch using text editors.
5930
5931    However, empty lines are OK.
5932
5933 `--exclude-vcs'
5934      Exclude files and directories used by following version control
5935      systems: `CVS', `RCS', `SCCS', `SVN', `Arch', `Bazaar',
5936      `Mercurial', and `Darcs'.
5937
5938    As of version 1.21, the following files are excluded:
5939
5940    * `CVS/', and everything under it
5941
5942    * `RCS/', and everything under it
5943
5944    * `SCCS/', and everything under it
5945
5946    * `.git/', and everything under it
5947
5948    * `.gitignore'
5949
5950    * `.cvsignore'
5951
5952    * `.svn/', and everything under it
5953
5954    * `.arch-ids/', and everything under it
5955
5956    * `{arch}/', and everything under it
5957
5958    * `=RELEASE-ID'
5959
5960    * `=meta-update'
5961
5962    * `=update'
5963
5964    * `.bzr'
5965
5966    * `.bzrignore'
5967
5968    * `.bzrtags'
5969
5970    * `.hg'
5971
5972    * `.hgignore'
5973
5974    * `.hgrags'
5975
5976    * `_darcs'
5977
5978    When creating an archive, the `--exclude-caches' option family
5979 causes `tar' to exclude all directories that contain a "cache directory
5980 tag". A cache directory tag is a short file with the well-known name
5981 `CACHEDIR.TAG' and having a standard header specified in
5982 `http://www.brynosaurus.com/cachedir/spec.html'.  Various applications
5983 write cache directory tags into directories they use to hold
5984 regenerable, non-precious data, so that such data can be more easily
5985 excluded from backups.
5986
5987    There are three `exclude-caches' options, each providing a different
5988 exclusion semantics:
5989
5990 `--exclude-caches'
5991      Do not archive the contents of the directory, but archive the
5992      directory itself and the `CACHEDIR.TAG' file.
5993
5994 `--exclude-caches-under'
5995      Do not archive the contents of the directory, nor the
5996      `CACHEDIR.TAG' file, archive only the directory itself.
5997
5998 `--exclude-caches-all'
5999      Omit directories containing `CACHEDIR.TAG' file entirely.
6000
6001    Another option family, `--exclude-tag', provides a generalization of
6002 this concept.  It takes a single argument, a file name to look for.
6003 Any directory that contains this file will be excluded from the dump.
6004 Similarly to `exclude-caches', there are three options in this option
6005 family:
6006
6007 `--exclude-tag=FILE'
6008      Do not dump the contents of the directory, but dump the directory
6009      itself and the FILE.
6010
6011 `--exclude-tag-under=FILE'
6012      Do not dump the contents of the directory, nor the FILE, archive
6013      only the directory itself.
6014
6015 `--exclude-tag-all=FILE'
6016      Omit directories containing FILE file entirely.
6017
6018    Multiple `--exclude-tag*' options can be given.
6019
6020    For example, given this directory:
6021
6022      $ find dir
6023      dir
6024      dir/blues
6025      dir/jazz
6026      dir/folk
6027      dir/folk/tagfile
6028      dir/folk/sanjuan
6029      dir/folk/trote
6030
6031    The `--exclude-tag' will produce the following:
6032
6033      $ tar -cf archive.tar --exclude-tag=tagfile -v dir
6034      dir/
6035      dir/blues
6036      dir/jazz
6037      dir/folk/
6038      tar: dir/folk/: contains a cache directory tag tagfile;
6039        contents not dumped
6040      dir/folk/tagfile
6041
6042    Both the `dir/folk' directory and its tagfile are preserved in the
6043 archive, however the rest of files in this directory are not.
6044
6045    Now, using the `--exclude-tag-under' option will exclude `tagfile'
6046 from the dump, while still preserving the directory itself, as shown in
6047 this example:
6048
6049      $ tar -cf archive.tar --exclude-tag-under=tagfile -v dir
6050      dir/
6051      dir/blues
6052      dir/jazz
6053      dir/folk/
6054      ./tar: dir/folk/: contains a cache directory tag tagfile;
6055        contents not dumped
6056
6057    Finally, using `--exclude-tag-all' omits the `dir/folk' directory
6058 entirely:
6059
6060      $ tar -cf archive.tar --exclude-tag-all=tagfile -v dir
6061      dir/
6062      dir/blues
6063      dir/jazz
6064      ./tar: dir/folk/: contains a cache directory tag tagfile;
6065        directory not dumped
6066
6067 * Menu:
6068
6069 * problems with exclude::
6070
6071 \1f
6072 File: tar.info,  Node: problems with exclude,  Up: exclude
6073
6074 Problems with Using the `exclude' Options
6075 -----------------------------------------
6076
6077 Some users find `exclude' options confusing.  Here are some common
6078 pitfalls:
6079
6080    * The main operating mode of `tar' does not act on a file name
6081      explicitly listed on the command line, if one of its file name
6082      components is excluded.  In the example above, if you create an
6083      archive and exclude files that end with `*.o', but explicitly name
6084      the file `dir.o/foo' after all the options have been listed,
6085      `dir.o/foo' will be excluded from the archive.
6086
6087    * You can sometimes confuse the meanings of `--exclude' and
6088      `--exclude-from'.  Be careful: use `--exclude' when files to be
6089      excluded are given as a pattern on the command line.  Use
6090      `--exclude-from' to introduce the name of a file which contains a
6091      list of patterns, one per line; each of these patterns can exclude
6092      zero, one, or many files.
6093
6094    * When you use `--exclude=PATTERN', be sure to quote the PATTERN
6095      parameter, so GNU `tar' sees wildcard characters like `*'.  If you
6096      do not do this, the shell might expand the `*' itself using files
6097      at hand, so `tar' might receive a list of files instead of one
6098      pattern, or none at all, making the command somewhat illegal.
6099      This might not correspond to what you want.
6100
6101      For example, write:
6102
6103           $ tar -c -f ARCHIVE.TAR --exclude '*.o' DIRECTORY
6104
6105      rather than:
6106
6107           # _Wrong!_
6108           $ tar -c -f ARCHIVE.TAR --exclude *.o DIRECTORY
6109
6110    * You must use use shell syntax, or globbing, rather than `regexp'
6111      syntax, when using exclude options in `tar'.  If you try to use
6112      `regexp' syntax to describe files to be excluded, your command
6113      might fail.
6114
6115    *  In earlier versions of `tar', what is now the `--exclude-from'
6116      option was called `--exclude' instead.  Now, `--exclude' applies
6117      to patterns listed on the command line and `--exclude-from'
6118      applies to patterns listed in a file.
6119
6120
6121 \1f
6122 File: tar.info,  Node: wildcards,  Next: quoting styles,  Prev: exclude,  Up: Choosing
6123
6124 6.5 Wildcards Patterns and Matching
6125 ===================================
6126
6127 "Globbing" is the operation by which "wildcard" characters, `*' or `?'
6128 for example, are replaced and expanded into all existing files matching
6129 the given pattern.  GNU `tar' can use wildcard patterns for matching
6130 (or globbing) archive members when extracting from or listing an
6131 archive.  Wildcard patterns are also used for verifying volume labels
6132 of `tar' archives.  This section has the purpose of explaining wildcard
6133 syntax for `tar'.
6134
6135    A PATTERN should be written according to shell syntax, using wildcard
6136 characters to effect globbing.  Most characters in the pattern stand
6137 for themselves in the matched string, and case is significant: `a' will
6138 match only `a', and not `A'.  The character `?' in the pattern matches
6139 any single character in the matched string.  The character `*' in the
6140 pattern matches zero, one, or more single characters in the matched
6141 string.  The character `\' says to take the following character of the
6142 pattern _literally_; it is useful when one needs to match the `?', `*',
6143 `[' or `\' characters, themselves.
6144
6145    The character `[', up to the matching `]', introduces a character
6146 class.  A "character class" is a list of acceptable characters for the
6147 next single character of the matched string.  For example, `[abcde]'
6148 would match any of the first five letters of the alphabet.  Note that
6149 within a character class, all of the "special characters" listed above
6150 other than `\' lose their special meaning; for example, `[-\\[*?]]'
6151 would match any of the characters, `-', `\', `[', `*', `?', or `]'.
6152 (Due to parsing constraints, the characters `-' and `]' must either
6153 come _first_ or _last_ in a character class.)
6154
6155    If the first character of the class after the opening `[' is `!' or
6156 `^', then the meaning of the class is reversed.  Rather than listing
6157 character to match, it lists those characters which are _forbidden_ as
6158 the next single character of the matched string.
6159
6160    Other characters of the class stand for themselves.  The special
6161 construction `[A-E]', using an hyphen between two letters, is meant to
6162 represent all characters between A and E, inclusive.
6163
6164    Periods (`.') or forward slashes (`/') are not considered special
6165 for wildcard matches.  However, if a pattern completely matches a
6166 directory prefix of a matched string, then it matches the full matched
6167 string: thus, excluding a directory also excludes all the files beneath
6168 it.
6169
6170 * Menu:
6171
6172 * controlling pattern-matching::
6173
6174 \1f
6175 File: tar.info,  Node: controlling pattern-matching,  Up: wildcards
6176
6177 Controlling Pattern-Matching
6178 ----------------------------
6179
6180 For the purposes of this section, we call "exclusion members" all
6181 member names obtained while processing `--exclude' and `--exclude-from'
6182 options, and "inclusion members" those member names that were given in
6183 the command line or read from the file specified with `--files-from'
6184 option.
6185
6186    These two pairs of member lists are used in the following operations:
6187 `--diff', `--extract', `--list', `--update'.
6188
6189    There are no inclusion members in create mode (`--create' and
6190 `--append'), since in this mode the names obtained from the command
6191 line refer to _files_, not archive members.
6192
6193    By default, inclusion members are compared with archive members
6194 literally (1) and exclusion members are treated as globbing patterns.
6195 For example:
6196
6197      $ tar tf foo.tar
6198      a.c
6199      b.c
6200      a.txt
6201      [remarks]
6202      # Member names are used verbatim:
6203      $ tar -xf foo.tar -v '[remarks]'
6204      [remarks]
6205      # Exclude member names are globbed:
6206      $ tar -xf foo.tar -v --exclude '*.c'
6207      a.txt
6208      [remarks]
6209
6210    This behavior can be altered by using the following options:
6211
6212 `--wildcards'
6213      Treat all member names as wildcards.
6214
6215 `--no-wildcards'
6216      Treat all member names as literal strings.
6217
6218    Thus, to extract files whose names end in `.c', you can use:
6219
6220      $ tar -xf foo.tar -v --wildcards '*.c'
6221      a.c
6222      b.c
6223
6224 Notice quoting of the pattern to prevent the shell from interpreting it.
6225
6226    The effect of `--wildcards' option is canceled by `--no-wildcards'.
6227 This can be used to pass part of the command line arguments verbatim
6228 and other part as globbing patterns.  For example, the following
6229 invocation:
6230
6231      $ tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'
6232
6233 instructs `tar' to extract from `foo.tar' all files whose names end in
6234 `.txt' and the file named `[remarks]'.
6235
6236    Normally, a pattern matches a name if an initial subsequence of the
6237 name's components matches the pattern, where `*', `?', and `[...]' are
6238 the usual shell wildcards, `\' escapes wildcards, and wildcards can
6239 match `/'.
6240
6241    Other than optionally stripping leading `/' from names (*note
6242 absolute::), patterns and names are used as-is.  For example, trailing
6243 `/' is not trimmed from a user-specified name before deciding whether
6244 to exclude it.
6245
6246    However, this matching procedure can be altered by the options listed
6247 below.  These options accumulate.  For example:
6248
6249      --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
6250
6251 ignores case when excluding `makefile', but not when excluding `readme'.
6252
6253 `--anchored'
6254 `--no-anchored'
6255      If anchored, a pattern must match an initial subsequence of the
6256      name's components.  Otherwise, the pattern can match any
6257      subsequence.  Default is `--no-anchored' for exclusion members and
6258      `--anchored' inclusion members.
6259
6260 `--ignore-case'
6261 `--no-ignore-case'
6262      When ignoring case, upper-case patterns match lower-case names and
6263      vice versa.  When not ignoring case (the default), matching is
6264      case-sensitive.
6265
6266 `--wildcards-match-slash'
6267 `--no-wildcards-match-slash'
6268      When wildcards match slash (the default for exclusion members), a
6269      wildcard like `*' in the pattern can match a `/' in the name.
6270      Otherwise, `/' is matched only by `/'.
6271
6272
6273    The `--recursion' and `--no-recursion' options (*note recurse::)
6274 also affect how member patterns are interpreted.  If recursion is in
6275 effect, a pattern matches a name if it matches any of the name's parent
6276 directories.
6277
6278    The following table summarizes pattern-matching default values:
6279
6280 Members                Default settings
6281 -------------------------------------------------------------------------- 
6282 Inclusion              `--no-wildcards --anchored
6283                        --no-wildcards-match-slash'
6284 Exclusion              `--wildcards --no-anchored
6285                        --wildcards-match-slash'
6286
6287    ---------- Footnotes ----------
6288
6289    (1) Notice that earlier GNU `tar' versions used globbing for
6290 inclusion members, which contradicted to UNIX98 specification and was
6291 not documented. *Note Changes::, for more information on this and other
6292 changes.
6293
6294 \1f
6295 File: tar.info,  Node: quoting styles,  Next: transform,  Prev: wildcards,  Up: Choosing
6296
6297 6.6 Quoting Member Names
6298 ========================
6299
6300 When displaying member names, `tar' takes care to avoid ambiguities
6301 caused by certain characters.  This is called "name quoting".  The
6302 characters in question are:
6303
6304    * Non-printable control characters:
6305      Character     ASCII   Character name
6306      --------------------------------------------------------------- 
6307      \a            7       Audible bell
6308      \b            8       Backspace
6309      \f            12      Form feed
6310      \n            10      New line
6311      \r            13      Carriage return
6312      \t            9       Horizontal tabulation
6313      \v            11      Vertical tabulation
6314
6315    * Space (ASCII 32)
6316
6317    * Single and double quotes (`'' and `"')
6318
6319    * Backslash (`\')
6320
6321    The exact way `tar' uses to quote these characters depends on the
6322 "quoting style".  The default quoting style, called "escape" (see
6323 below), uses backslash notation to represent control characters, space
6324 and backslash.  Using this quoting style, control characters are
6325 represented as listed in column `Character' in the above table, a space
6326 is printed as `\ ' and a backslash as `\\'.
6327
6328    GNU `tar' offers seven distinct quoting styles, which can be selected
6329 using `--quoting-style' option:
6330
6331 `--quoting-style=STYLE'
6332      Sets quoting style.  Valid values for STYLE argument are: literal,
6333      shell, shell-always, c, escape, locale, clocale.
6334
6335    These styles are described in detail below.  To illustrate their
6336 effect, we will use an imaginary tar archive `arch.tar' containing the
6337 following members:
6338
6339      # 1. Contains horizontal tabulation character.
6340      a       tab
6341      # 2. Contains newline character
6342      a
6343      newline
6344      # 3. Contains a space
6345      a space
6346      # 4. Contains double quotes
6347      a"double"quote
6348      # 5. Contains single quotes
6349      a'single'quote
6350      # 6. Contains a backslash character:
6351      a\backslash
6352
6353    Here is how usual `ls' command would have listed them, if they had
6354 existed in the current working directory:
6355
6356      $ ls
6357      a\ttab
6358      a\nnewline
6359      a\ space
6360      a"double"quote
6361      a'single'quote
6362      a\\backslash
6363
6364    Quoting styles:
6365
6366 `literal'
6367      No quoting, display each character as is:
6368
6369           $ tar tf arch.tar --quoting-style=literal
6370           ./
6371           ./a space
6372           ./a'single'quote
6373           ./a"double"quote
6374           ./a\backslash
6375           ./a     tab
6376           ./a
6377           newline
6378
6379 `shell'
6380      Display characters the same way Bourne shell does: control
6381      characters, except `\t' and `\n', are printed using backslash
6382      escapes, `\t' and `\n' are printed as is, and a single quote is
6383      printed as `\''.  If a name contains any quoted characters, it is
6384      enclosed in single quotes.  In particular, if a name contains
6385      single quotes, it is printed as several single-quoted strings:
6386
6387           $ tar tf arch.tar --quoting-style=shell
6388           ./
6389           './a space'
6390           './a'\''single'\''quote'
6391           './a"double"quote'
6392           './a\backslash'
6393           './a    tab'
6394           './a
6395           newline'
6396
6397 `shell-always'
6398      Same as `shell', but the names are always enclosed in single
6399      quotes:
6400
6401           $ tar tf arch.tar --quoting-style=shell-always
6402           './'
6403           './a space'
6404           './a'\''single'\''quote'
6405           './a"double"quote'
6406           './a\backslash'
6407           './a    tab'
6408           './a
6409           newline'
6410
6411 `c'
6412      Use the notation of the C programming language.  All names are
6413      enclosed in double quotes.  Control characters are quoted using
6414      backslash notations, double quotes are represented as `\"',
6415      backslash characters are represented as `\\'.  Single quotes and
6416      spaces are not quoted:
6417
6418           $ tar tf arch.tar --quoting-style=c
6419           "./"
6420           "./a space"
6421           "./a'single'quote"
6422           "./a\"double\"quote"
6423           "./a\\backslash"
6424           "./a\ttab"
6425           "./a\nnewline"
6426
6427 `escape'
6428      Control characters are printed using backslash notation, a space is
6429      printed as `\ ' and a backslash as `\\'.  This is the default
6430      quoting style, unless it was changed when configured the package.
6431
6432           $ tar tf arch.tar --quoting-style=escape
6433           ./
6434           ./a space
6435           ./a'single'quote
6436           ./a"double"quote
6437           ./a\\backslash
6438           ./a\ttab
6439           ./a\nnewline
6440
6441 `locale'
6442      Control characters, single quote and backslash are printed using
6443      backslash notation.  All names are quoted using left and right
6444      quotation marks, appropriate to the current locale.  If it does not
6445      define quotation marks, use ``' as left and `'' as right quotation
6446      marks.  Any occurrences of the right quotation mark in a name are
6447      escaped with `\', for example:
6448
6449      For example:
6450
6451           $ tar tf arch.tar --quoting-style=locale
6452           `./'
6453           `./a space'
6454           `./a\'single\'quote'
6455           `./a"double"quote'
6456           `./a\\backslash'
6457           `./a\ttab'
6458           `./a\nnewline'
6459
6460 `clocale'
6461      Same as `locale', but `"' is used for both left and right
6462      quotation marks, if not provided by the currently selected locale:
6463
6464           $ tar tf arch.tar --quoting-style=clocale
6465           "./"
6466           "./a space"
6467           "./a'single'quote"
6468           "./a\"double\"quote"
6469           "./a\\backslash"
6470           "./a\ttab"
6471           "./a\nnewline"
6472
6473    You can specify which characters should be quoted in addition to
6474 those implied by the current quoting style:
6475
6476 `--quote-chars=STRING'
6477      Always quote characters from STRING, even if the selected quoting
6478      style would not quote them.
6479
6480    For example, using `escape' quoting (compare with the usual escape
6481 listing above):
6482
6483      $ tar tf arch.tar --quoting-style=escape --quote-chars=' "'
6484      ./
6485      ./a\ space
6486      ./a'single'quote
6487      ./a\"double\"quote
6488      ./a\\backslash
6489      ./a\ttab
6490      ./a\nnewline
6491
6492    To disable quoting of such additional characters, use the following
6493 option:
6494
6495 `--no-quote-chars=STRING'
6496      Remove characters listed in STRING from the list of quoted
6497      characters set by the previous `--quote-chars' option.
6498
6499    This option is particularly useful if you have added `--quote-chars'
6500 to your `TAR_OPTIONS' (*note TAR_OPTIONS::) and wish to disable it for
6501 the current invocation.
6502
6503    Note, that `--no-quote-chars' does _not_ disable those characters
6504 that are quoted by default in the selected quoting style.
6505
6506 \1f
6507 File: tar.info,  Node: transform,  Next: after,  Prev: quoting styles,  Up: Choosing
6508
6509 6.7 Modifying File and Member Names
6510 ===================================
6511
6512 `Tar' archives contain detailed information about files stored in them
6513 and full file names are part of that information.  When storing file to
6514 an archive, its file name is recorded in it, along with the actual file
6515 contents.  When restoring from an archive, a file is created on disk
6516 with exactly the same name as that stored in the archive.  In the
6517 majority of cases this is the desired behavior of a file archiver.
6518 However, there are some cases when it is not.
6519
6520    First of all, it is often unsafe to extract archive members with
6521 absolute file names or those that begin with a `../'.  GNU `tar' takes
6522 special precautions when extracting such names and provides a special
6523 option for handling them, which is described in *note absolute::.
6524
6525    Secondly, you may wish to extract file names without some leading
6526 directory components, or with otherwise modified names.  In other cases
6527 it is desirable to store files under differing names in the archive.
6528
6529    GNU `tar' provides several options for these needs.
6530
6531 `--strip-components=NUMBER'
6532      Strip given NUMBER of leading components from file names before
6533      extraction.
6534
6535    For example, suppose you have archived whole `/usr' hierarchy to a
6536 tar archive named `usr.tar'.  Among other files, this archive contains
6537 `usr/include/stdlib.h', which you wish to extract to the current
6538 working directory.  To do so, you type:
6539
6540      $ tar -xf usr.tar --strip=2 usr/include/stdlib.h
6541
6542    The option `--strip=2' instructs `tar' to strip the two leading
6543 components (`usr/' and `include/') off the file name.
6544
6545    If you add the `--verbose' (`-v') option to the invocation above,
6546 you will note that the verbose listing still contains the full file
6547 name, with the two removed components still in place.  This can be
6548 inconvenient, so `tar' provides a special option for altering this
6549 behavior:
6550
6551 `--show-transformed-names'
6552      Display file or member names with all requested transformations
6553      applied.
6554
6555 For example:
6556
6557      $ tar -xf usr.tar -v --strip=2 usr/include/stdlib.h
6558      usr/include/stdlib.h
6559      $ tar -xf usr.tar -v --strip=2 --show-transformed usr/include/stdlib.h
6560      stdlib.h
6561
6562    Notice that in both cases the file `stdlib.h' is extracted to the
6563 current working directory, `--show-transformed-names' affects only the
6564 way its name is displayed.
6565
6566    This option is especially useful for verifying whether the invocation
6567 will have the desired effect.  Thus, before running
6568
6569      $ tar -x --strip=N
6570
6571 it is often advisable to run
6572
6573      $ tar -t -v --show-transformed --strip=N
6574
6575 to make sure the command will produce the intended results.
6576
6577    In case you need to apply more complex modifications to the file
6578 name, GNU `tar' provides a general-purpose transformation option:
6579
6580 `--transform=EXPRESSION'
6581 `--xform=EXPRESSION'
6582      Modify file names using supplied EXPRESSION.
6583
6584 The EXPRESSION is a `sed'-like replace expression of the form:
6585
6586      s/REGEXP/REPLACE/[FLAGS]
6587
6588 where REGEXP is a "regular expression", REPLACE is a replacement for
6589 each file name part that matches REGEXP.  Both REGEXP and REPLACE are
6590 described in detail in *note The "s" Command: (sed)The "s" Command.
6591
6592    Any delimiter can be used in lieue of `/', the only requirement being
6593 that it be used consistently throughout the expression. For example,
6594 the following two expressions are equivalent:
6595
6596      s/one/two/
6597      s,one,two,
6598
6599    Changing delimiters is often useful when the REGEX contains slashes.
6600 For example, it is more convenient to write `s,/,-,' than `s/\//-/'.
6601
6602    As in `sed', you can give several replace expressions, separated by
6603 a semicolon.
6604
6605    Supported FLAGS are:
6606
6607 `g'
6608      Apply the replacement to _all_ matches to the REGEXP, not just the
6609      first.
6610
6611 `i'
6612      Use case-insensitive matching
6613
6614 `x'
6615      REGEXP is an "extended regular expression" (*note Extended regular
6616      expressions: (sed)Extended regexps.).
6617
6618 `NUMBER'
6619      Only replace the NUMBERth match of the REGEXP.
6620
6621      Note: the POSIX standard does not specify what should happen when
6622      you mix the `g' and NUMBER modifiers.  GNU `tar' follows the GNU
6623      `sed' implementation in this regard, so the interaction is defined
6624      to be: ignore matches before the NUMBERth, and then match and
6625      replace all matches from the NUMBERth on.
6626
6627
6628    In addition, several "transformation scope" flags are supported,
6629 that control to what files transformations apply.  These are:
6630
6631 `r'
6632      Apply transformation to regular archive members.
6633
6634 `R'
6635      Do not apply transformation to regular archive members.
6636
6637 `s'
6638      Apply transformation to symbolic link targets.
6639
6640 `S'
6641      Do not apply transformation to symbolic link targets.
6642
6643 `h'
6644      Apply transformation to hard link targets.
6645
6646 `H'
6647      Do not apply transformation to hard link targets.
6648
6649    Default is `rsh', which means to apply tranformations to both archive
6650 members and targets of symbolic and hard links.
6651
6652    Default scope flags can also be changed using `flags=' statement in
6653 the transform expression.  The flags set this way remain in force until
6654 next `flags=' statement or end of expression, whichever occurs first.
6655 For example:
6656
6657        --transform 'flags=S;s|^|/usr/local/|'
6658
6659    Here are several examples of `--transform' usage:
6660
6661   1. Extract `usr/' hierarchy into `usr/local/':
6662
6663           $ tar --transform='s,usr/,usr/local/,' -x -f arch.tar
6664
6665   2. Strip two leading directory components (equivalent to
6666      `--strip-components=2'):
6667
6668           $ tar --transform='s,/*[^/]*/[^/]*/,,' -x -f arch.tar
6669
6670   3. Convert each file name to lower case:
6671
6672           $ tar --transform 's/.*/\L&/' -x -f arch.tar
6673
6674   4. Prepend `/prefix/'  to each file name:
6675
6676           $ tar --transform 's,^,/prefix/,' -x -f arch.tar
6677
6678   5. Archive the `/lib' directory, prepending `/usr/local' to each
6679      archive member:
6680
6681           $ tar --transform 's,^,/usr/local/,S' -c -f arch.tar /lib
6682
6683    Notice the use of flags in the last example.  The `/lib' directory
6684 often contains many symbolic links to files within it.  It may look,
6685 for example, like this:
6686
6687      $ ls -l
6688      drwxr-xr-x root/root       0 2008-07-08 16:20 /lib/
6689      -rwxr-xr-x root/root 1250840 2008-05-25 07:44 /lib/libc-2.3.2.so
6690      lrwxrwxrwx root/root       0 2008-06-24 17:12 /lib/libc.so.6 -> libc-2.3.2.so
6691      ...
6692
6693    Using the expression `s,^,/usr/local/,' would mean adding
6694 `/usr/local' to both regular archive members and to link targets. In
6695 this case, `/lib/libc.so.6' would become:
6696
6697        /usr/local/lib/libc.so.6 -> /usr/local/libc-2.3.2.so
6698
6699    This is definitely not desired.  To avoid this, the `S' flag are
6700 used, which excludes symbolic link targets from filename
6701 transformations.  The result is:
6702
6703      $ tar --transform 's,^,/usr/local/,S', -c -v -f arch.tar \
6704             --show-transformed /lib
6705      drwxr-xr-x root/root       0 2008-07-08 16:20 /usr/local/lib/
6706      -rwxr-xr-x root/root 1250840 2008-05-25 07:44 /usr/local/lib/libc-2.3.2.so
6707      lrwxrwxrwx root/root       0 2008-06-24 17:12 /usr/local/lib/libc.so.6 ->
6708      libc-2.3.2.so
6709
6710    Unlike `--strip-components', `--transform' can be used in any GNU
6711 `tar' operation mode.  For example, the following command adds files to
6712 the archive while replacing the leading `usr/' component with `var/':
6713
6714      $ tar -cf arch.tar --transform='s,^usr/,var/,' /
6715
6716    To test `--transform' effect we suggest using
6717 `--show-transformed-names' option:
6718
6719      $ tar -cf arch.tar --transform='s,^usr/,var/,' \
6720             --verbose --show-transformed-names /
6721
6722    If both `--strip-components' and `--transform' are used together,
6723 then `--transform' is applied first, and the required number of
6724 components is then stripped from its result.
6725
6726    You can use as many `--transform' options in a single command line
6727 as you want.  The specified expressions will then be applied in order
6728 of their appearance.  For example, the following two invocations are
6729 equivalent:
6730
6731      $ tar -cf arch.tar --transform='s,/usr/var,/var/' \
6732                              --transform='s,/usr/local,/usr/,'
6733      $ tar -cf arch.tar \
6734                     --transform='s,/usr/var,/var/;s,/usr/local,/usr/,'
6735
6736 \1f
6737 File: tar.info,  Node: after,  Next: recurse,  Prev: transform,  Up: Choosing
6738
6739 6.8 Operating Only on New Files
6740 ===============================
6741
6742      _(This message will disappear, once this node revised.)_
6743
6744 The `--after-date=DATE' (`--newer=DATE', `-N DATE') option causes `tar'
6745 to only work on files whose data modification or status change times
6746 are newer than the DATE given.  If DATE starts with `/' or `.', it is
6747 taken to be a file name; the data modification time of that file is
6748 used as the date. If you use this option when creating or appending to
6749 an archive, the archive will only include new files.  If you use
6750 `--after-date' when extracting an archive, `tar' will only extract
6751 files newer than the DATE you specify.
6752
6753    If you only want `tar' to make the date comparison based on
6754 modification of the file's data (rather than status changes), then use
6755 the `--newer-mtime=DATE' option.
6756
6757    You may use these options with any operation.  Note that these
6758 options differ from the `--update' (`-u') operation in that they allow
6759 you to specify a particular date against which `tar' can compare when
6760 deciding whether or not to archive the files.
6761
6762 `--after-date=DATE'
6763 `--newer=DATE'
6764 `-N DATE'
6765      Only store files newer than DATE.
6766
6767      Acts on files only if their data modification or status change
6768      times are later than DATE.  Use in conjunction with any operation.
6769
6770      If DATE starts with `/' or `.', it is taken to be a file name; the
6771      data modification time of that file is used as the date.
6772
6773 `--newer-mtime=DATE'
6774      Acts like `--after-date', but only looks at data modification
6775      times.
6776
6777    These options limit `tar' to operate only on files which have been
6778 modified after the date specified.  A file's status is considered to
6779 have changed if its contents have been modified, or if its owner,
6780 permissions, and so forth, have been changed.  (For more information on
6781 how to specify a date, see *note Date input formats::; remember that the
6782 entire date argument must be quoted if it contains any spaces.)
6783
6784    Gurus would say that `--after-date' tests both the data modification
6785 time (`mtime', the time the contents of the file were last modified)
6786 and the status change time (`ctime', the time the file's status was
6787 last changed: owner, permissions, etc.)  fields, while `--newer-mtime'
6788 tests only the `mtime' field.
6789
6790    To be precise, `--after-date' checks _both_ `mtime' and `ctime' and
6791 processes the file if either one is more recent than DATE, while
6792 `--newer-mtime' only checks `mtime' and disregards `ctime'.  Neither
6793 does it use `atime' (the last time the contents of the file were looked
6794 at).
6795
6796    Date specifiers can have embedded spaces.  Because of this, you may
6797 need to quote date arguments to keep the shell from parsing them as
6798 separate arguments.  For example, the following command will add to the
6799 archive all the files modified less than two days ago:
6800
6801      $ tar -cf foo.tar --newer-mtime '2 days ago'
6802
6803    When any of these options is used with the option `--verbose' (*note
6804 verbose tutorial::) GNU `tar' will try to convert the specified date
6805 back to its textual representation and compare that with the one given
6806 with the option.  If the two dates differ, `tar' will print a warning
6807 saying what date it will use.  This is to help user ensure he is using
6808 the right date.  For example:
6809
6810      $ tar -c -f archive.tar --after-date='10 days ago' .
6811      tar: Option --after-date: Treating date `10 days ago' as 2006-06-11
6812      13:19:37.232434
6813
6814      *Please Note:* `--after-date' and `--newer-mtime' should not be
6815      used for incremental backups.  *Note Incremental Dumps::, for
6816      proper way of creating incremental backups.
6817
6818 \1f
6819 File: tar.info,  Node: recurse,  Next: one,  Prev: after,  Up: Choosing
6820
6821 6.9 Descending into Directories
6822 ===============================
6823
6824      _(This message will disappear, once this node revised.)_
6825
6826 Usually, `tar' will recursively explore all directories (either those
6827 given on the command line or through the `--files-from' option) for the
6828 various files they contain.  However, you may not always want `tar' to
6829 act this way.
6830
6831    The `--no-recursion' option inhibits `tar''s recursive descent into
6832 specified directories.  If you specify `--no-recursion', you can use
6833 the `find' utility for hunting through levels of directories to
6834 construct a list of file names which you could then pass to `tar'.
6835 `find' allows you to be more selective when choosing which files to
6836 archive; see *note files::, for more information on using `find' with
6837 `tar', or look.
6838
6839 `--no-recursion'
6840      Prevents `tar' from recursively descending directories.
6841
6842 `--recursion'
6843      Requires `tar' to recursively descend directories.  This is the
6844      default.
6845
6846    When you use `--no-recursion', GNU `tar' grabs directory entries
6847 themselves, but does not descend on them recursively.  Many people use
6848 `find' for locating files they want to back up, and since `tar'
6849 _usually_ recursively descends on directories, they have to use the
6850 `-not -type d' test in their `find' invocation (*note Type:
6851 (find)Type.), as they usually do not want all the files in a directory.
6852 They then use the `--files-from' option to archive the files located
6853 via `find'.
6854
6855    The problem when restoring files archived in this manner is that the
6856 directories themselves are not in the archive; so the
6857 `--same-permissions' (`--preserve-permissions', `-p') option does not
6858 affect them--while users might really like it to.  Specifying
6859 `--no-recursion' is a way to tell `tar' to grab only the directory
6860 entries given to it, adding no new files on its own.  To summarize, if
6861 you use `find' to create a list of files to be stored in an archive,
6862 use it as follows:
6863
6864      $ find DIR TESTS | \
6865        tar -cf ARCHIVE -T - --no-recursion
6866
6867    The `--no-recursion' option also applies when extracting: it causes
6868 `tar' to extract only the matched directory entries, not the files
6869 under those directories.
6870
6871    The `--no-recursion' option also affects how globbing patterns are
6872 interpreted (*note controlling pattern-matching::).
6873
6874    The `--no-recursion' and `--recursion' options apply to later
6875 options and operands, and can be overridden by later occurrences of
6876 `--no-recursion' and `--recursion'.  For example:
6877
6878      $ tar -cf jams.tar --no-recursion grape --recursion grape/concord
6879
6880 creates an archive with one entry for `grape', and the recursive
6881 contents of `grape/concord', but no entries under `grape' other than
6882 `grape/concord'.
6883
6884 \1f
6885 File: tar.info,  Node: one,  Prev: recurse,  Up: Choosing
6886
6887 6.10 Crossing File System Boundaries
6888 ====================================
6889
6890      _(This message will disappear, once this node revised.)_
6891
6892 `tar' will normally automatically cross file system boundaries in order
6893 to archive files which are part of a directory tree.  You can change
6894 this behavior by running `tar' and specifying `--one-file-system'.
6895 This option only affects files that are archived because they are in a
6896 directory that is being archived; `tar' will still archive files
6897 explicitly named on the command line or through `--files-from',
6898 regardless of where they reside.
6899
6900 `--one-file-system'
6901      Prevents `tar' from crossing file system boundaries when
6902      archiving.  Use in conjunction with any write operation.
6903
6904    The `--one-file-system' option causes `tar' to modify its normal
6905 behavior in archiving the contents of directories.  If a file in a
6906 directory is not on the same file system as the directory itself, then
6907 `tar' will not archive that file.  If the file is a directory itself,
6908 `tar' will not archive anything beneath it; in other words, `tar' will
6909 not cross mount points.
6910
6911    This option is useful for making full or incremental archival
6912 backups of a file system.  If this option is used in conjunction with
6913 `--verbose' (`-v'), files that are excluded are mentioned by name on
6914 the standard error.
6915
6916 * Menu:
6917
6918 * directory::                   Changing Directory
6919 * absolute::                    Absolute File Names
6920
6921 \1f
6922 File: tar.info,  Node: directory,  Next: absolute,  Up: one
6923
6924 6.10.1 Changing the Working Directory
6925 -------------------------------------
6926
6927 To change the working directory in the middle of a list of file names,
6928 either on the command line or in a file specified using `--files-from'
6929 (`-T'), use `--directory' (`-C').  This will change the working
6930 directory to the specified directory after that point in the list.
6931
6932 `--directory=DIRECTORY'
6933 `-C DIRECTORY'
6934      Changes the working directory in the middle of a command line.
6935
6936    For example,
6937
6938      $ tar -c -f jams.tar grape prune -C food cherry
6939
6940 will place the files `grape' and `prune' from the current directory
6941 into the archive `jams.tar', followed by the file `cherry' from the
6942 directory `food'.  This option is especially useful when you have
6943 several widely separated files that you want to store in the same
6944 archive.
6945
6946    Note that the file `cherry' is recorded in the archive under the
6947 precise name `cherry', _not_ `food/cherry'.  Thus, the archive will
6948 contain three files that all appear to have come from the same
6949 directory; if the archive is extracted with plain `tar --extract', all
6950 three files will be written in the current directory.
6951
6952    Contrast this with the command,
6953
6954      $ tar -c -f jams.tar grape prune -C food red/cherry
6955
6956 which records the third file in the archive under the name `red/cherry'
6957 so that, if the archive is extracted using `tar --extract', the third
6958 file will be written in a subdirectory named `orange-colored'.
6959
6960    You can use the `--directory' option to make the archive independent
6961 of the original name of the directory holding the files.  The following
6962 command places the files `/etc/passwd', `/etc/hosts', and `/lib/libc.a'
6963 into the archive `foo.tar':
6964
6965      $ tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a
6966
6967 However, the names of the archive members will be exactly what they were
6968 on the command line: `passwd', `hosts', and `libc.a'.  They will not
6969 appear to be related by file name to the original directories where
6970 those files were located.
6971
6972    Note that `--directory' options are interpreted consecutively.  If
6973 `--directory' specifies a relative file name, it is interpreted
6974 relative to the then current directory, which might not be the same as
6975 the original current working directory of `tar', due to a previous
6976 `--directory' option.
6977
6978    When using `--files-from' (*note files::), you can put various `tar'
6979 options (including `-C') in the file list.  Notice, however, that in
6980 this case the option and its argument may not be separated by
6981 whitespace.  If you use short option, its argument must either follow
6982 the option letter immediately, without any intervening whitespace, or
6983 occupy the next line.  Otherwise, if you use long option, separate its
6984 argument by an equal sign.
6985
6986    For instance, the file list for the above example will be:
6987
6988      -C/etc
6989      passwd
6990      hosts
6991      --directory=/lib
6992      libc.a
6993
6994 To use it, you would invoke `tar' as follows:
6995
6996      $ tar -c -f foo.tar --files-from list
6997
6998    The interpretation of `--directory' is disabled by `--null' option.
6999
7000 \1f
7001 File: tar.info,  Node: absolute,  Prev: directory,  Up: one
7002
7003 6.10.2 Absolute File Names
7004 --------------------------
7005
7006      _(This message will disappear, once this node revised.)_
7007
7008 `--absolute-names'
7009 `-P'
7010      Do not strip leading slashes from file names, and permit file names
7011      containing a `..' file name component.
7012
7013    By default, GNU `tar' drops a leading `/' on input or output, and
7014 complains about file names containing a `..' component.  This option
7015 turns off this behavior.
7016
7017    When `tar' extracts archive members from an archive, it strips any
7018 leading slashes (`/') from the member name.  This causes absolute
7019 member names in the archive to be treated as relative file names.  This
7020 allows you to have such members extracted wherever you want, instead of
7021 being restricted to extracting the member in the exact directory named
7022 in the archive.  For example, if the archive member has the name
7023 `/etc/passwd', `tar' will extract it as if the name were really
7024 `etc/passwd'.
7025
7026    File names containing `..' can cause problems when extracting, so
7027 `tar' normally warns you about such files when creating an archive, and
7028 rejects attempts to extracts such files.
7029
7030    Other `tar' programs do not do this.  As a result, if you create an
7031 archive whose member names start with a slash, they will be difficult
7032 for other people with a non-GNU `tar' program to use.  Therefore, GNU
7033 `tar' also strips leading slashes from member names when putting
7034 members into the archive.  For example, if you ask `tar' to add the file
7035 `/bin/ls' to an archive, it will do so, but the member name will be
7036 `bin/ls'.(1)
7037
7038    If you use the `--absolute-names' (`-P') option, `tar' will do none
7039 of these transformations.
7040
7041    To archive or extract files relative to the root directory, specify
7042 the `--absolute-names' (`-P') option.
7043
7044    Normally, `tar' acts on files relative to the working
7045 directory--ignoring superior directory names when archiving, and
7046 ignoring leading slashes when extracting.
7047
7048    When you specify `--absolute-names' (`-P'), `tar' stores file names
7049 including all superior directory names, and preserves leading slashes.
7050 If you only invoked `tar' from the root directory you would never need
7051 the `--absolute-names' option, but using this option may be more
7052 convenient than switching to root.
7053
7054 `--absolute-names'
7055      Preserves full file names (including superior directory names) when
7056      archiving files.  Preserves leading slash when extracting files.
7057
7058
7059    `tar' prints out a message about removing the `/' from file names.
7060 This message appears once per GNU `tar' invocation.  It represents
7061 something which ought to be told; ignoring what it means can cause very
7062 serious surprises, later.
7063
7064    Some people, nevertheless, do not want to see this message.  Wanting
7065 to play really dangerously, one may of course redirect `tar' standard
7066 error to the sink.  For example, under `sh':
7067
7068      $ tar -c -f archive.tar /home 2> /dev/null
7069
7070 Another solution, both nicer and simpler, would be to change to the `/'
7071 directory first, and then avoid absolute notation.  For example:
7072
7073      $ tar -c -f archive.tar -C / home
7074
7075    ---------- Footnotes ----------
7076
7077    (1) A side effect of this is that when `--create' is used with
7078 `--verbose' the resulting output is not, generally speaking, the same
7079 as the one you'd get running `tar --list' command.  This may be
7080 important if you use some scripts for comparing both outputs.  *Note
7081 listing member and file names::, for the information on how to handle
7082 this case.
7083
7084 \1f
7085 File: tar.info,  Node: Date input formats,  Next: Formats,  Prev: Choosing,  Up: Top
7086
7087 7 Date input formats
7088 ********************
7089
7090 First, a quote:
7091
7092      Our units of temporal measurement, from seconds on up to months,
7093      are so complicated, asymmetrical and disjunctive so as to make
7094      coherent mental reckoning in time all but impossible.  Indeed, had
7095      some tyrannical god contrived to enslave our minds to time, to
7096      make it all but impossible for us to escape subjection to sodden
7097      routines and unpleasant surprises, he could hardly have done
7098      better than handing down our present system.  It is like a set of
7099      trapezoidal building blocks, with no vertical or horizontal
7100      surfaces, like a language in which the simplest thought demands
7101      ornate constructions, useless particles and lengthy
7102      circumlocutions.  Unlike the more successful patterns of language
7103      and science, which enable us to face experience boldly or at least
7104      level-headedly, our system of temporal calculation silently and
7105      persistently encourages our terror of time.
7106
7107      ...  It is as though architects had to measure length in feet,
7108      width in meters and height in ells; as though basic instruction
7109      manuals demanded a knowledge of five different languages.  It is
7110      no wonder then that we often look into our own immediate past or
7111      future, last Tuesday or a week from Sunday, with feelings of
7112      helpless confusion.  ...
7113
7114      -- Robert Grudin, `Time and the Art of Living'.
7115
7116    This section describes the textual date representations that GNU
7117 programs accept.  These are the strings you, as a user, can supply as
7118 arguments to the various programs.  The C interface (via the `get_date'
7119 function) is not described here.
7120
7121 * Menu:
7122
7123 * General date syntax::            Common rules.
7124 * Calendar date items::            19 Dec 1994.
7125 * Time of day items::              9:20pm.
7126 * Time zone items::                EST, PDT, GMT.
7127 * Day of week items::              Monday and others.
7128 * Relative items in date strings:: next tuesday, 2 years ago.
7129 * Pure numbers in date strings::   19931219, 1440.
7130 * Seconds since the Epoch::        @1078100502.
7131 * Specifying time zone rules::     TZ="America/New_York", TZ="UTC0".
7132 * Authors of get_date::            Bellovin, Eggert, Salz, Berets, et al.
7133
7134 \1f
7135 File: tar.info,  Node: General date syntax,  Next: Calendar date items,  Up: Date input formats
7136
7137 7.1 General date syntax
7138 =======================
7139
7140 A "date" is a string, possibly empty, containing many items separated
7141 by whitespace.  The whitespace may be omitted when no ambiguity arises.
7142 The empty string means the beginning of today (i.e., midnight).  Order
7143 of the items is immaterial.  A date string may contain many flavors of
7144 items:
7145
7146    * calendar date items
7147
7148    * time of day items
7149
7150    * time zone items
7151
7152    * day of the week items
7153
7154    * relative items
7155
7156    * pure numbers.
7157
7158 We describe each of these item types in turn, below.
7159
7160    A few ordinal numbers may be written out in words in some contexts.
7161 This is most useful for specifying day of the week items or relative
7162 items (see below).  Among the most commonly used ordinal numbers, the
7163 word `last' stands for -1, `this' stands for 0, and `first' and `next'
7164 both stand for 1.  Because the word `second' stands for the unit of
7165 time there is no way to write the ordinal number 2, but for convenience
7166 `third' stands for 3, `fourth' for 4, `fifth' for 5, `sixth' for 6,
7167 `seventh' for 7, `eighth' for 8, `ninth' for 9, `tenth' for 10,
7168 `eleventh' for 11 and `twelfth' for 12.
7169
7170    When a month is written this way, it is still considered to be
7171 written numerically, instead of being "spelled in full"; this changes
7172 the allowed strings.
7173
7174    In the current implementation, only English is supported for words
7175 and abbreviations like `AM', `DST', `EST', `first', `January',
7176 `Sunday', `tomorrow', and `year'.
7177
7178    The output of the `date' command is not always acceptable as a date
7179 string, not only because of the language problem, but also because
7180 there is no standard meaning for time zone items like `IST'.  When using
7181 `date' to generate a date string intended to be parsed later, specify a
7182 date format that is independent of language and that does not use time
7183 zone items other than `UTC' and `Z'.  Here are some ways to do this:
7184
7185      $ LC_ALL=C TZ=UTC0 date
7186      Mon Mar  1 00:21:42 UTC 2004
7187      $ TZ=UTC0 date +'%Y-%m-%d %H:%M:%SZ'
7188      2004-03-01 00:21:42Z
7189      $ date --iso-8601=ns | tr T ' '  # --iso-8601 is a GNU extension.
7190      2004-02-29 16:21:42,692722128-0800
7191      $ date --rfc-2822  # a GNU extension
7192      Sun, 29 Feb 2004 16:21:42 -0800
7193      $ date +'%Y-%m-%d %H:%M:%S %z'  # %z is a GNU extension.
7194      2004-02-29 16:21:42 -0800
7195      $ date +'@%s.%N'  # %s and %N are GNU extensions.
7196      @1078100502.692722128
7197
7198    Alphabetic case is completely ignored in dates.  Comments may be
7199 introduced between round parentheses, as long as included parentheses
7200 are properly nested.  Hyphens not followed by a digit are currently
7201 ignored.  Leading zeros on numbers are ignored.
7202
7203    Invalid dates like `2005-02-29' or times like `24:00' are rejected.
7204 In the typical case of a host that does not support leap seconds, a
7205 time like `23:59:60' is rejected even if it corresponds to a valid leap
7206 second.
7207
7208 \1f
7209 File: tar.info,  Node: Calendar date items,  Next: Time of day items,  Prev: General date syntax,  Up: Date input formats
7210
7211 7.2 Calendar date items
7212 =======================
7213
7214 A "calendar date item" specifies a day of the year.  It is specified
7215 differently, depending on whether the month is specified numerically or
7216 literally.  All these strings specify the same calendar date:
7217
7218      1972-09-24     # ISO 8601.
7219      72-9-24        # Assume 19xx for 69 through 99,
7220                     # 20xx for 00 through 68.
7221      72-09-24       # Leading zeros are ignored.
7222      9/24/72        # Common U.S. writing.
7223      24 September 1972
7224      24 Sept 72     # September has a special abbreviation.
7225      24 Sep 72      # Three-letter abbreviations always allowed.
7226      Sep 24, 1972
7227      24-sep-72
7228      24sep72
7229
7230    The year can also be omitted.  In this case, the last specified year
7231 is used, or the current year if none.  For example:
7232
7233      9/24
7234      sep 24
7235
7236    Here are the rules.
7237
7238    For numeric months, the ISO 8601 format `YEAR-MONTH-DAY' is allowed,
7239 where YEAR is any positive number, MONTH is a number between 01 and 12,
7240 and DAY is a number between 01 and 31.  A leading zero must be present
7241 if a number is less than ten.  If YEAR is 68 or smaller, then 2000 is
7242 added to it; otherwise, if YEAR is less than 100, then 1900 is added to
7243 it.  The construct `MONTH/DAY/YEAR', popular in the United States, is
7244 accepted.  Also `MONTH/DAY', omitting the year.
7245
7246    Literal months may be spelled out in full: `January', `February',
7247 `March', `April', `May', `June', `July', `August', `September',
7248 `October', `November' or `December'.  Literal months may be abbreviated
7249 to their first three letters, possibly followed by an abbreviating dot.
7250 It is also permitted to write `Sept' instead of `September'.
7251
7252    When months are written literally, the calendar date may be given as
7253 any of the following:
7254
7255      DAY MONTH YEAR
7256      DAY MONTH
7257      MONTH DAY YEAR
7258      DAY-MONTH-YEAR
7259
7260    Or, omitting the year:
7261
7262      MONTH DAY
7263
7264 \1f
7265 File: tar.info,  Node: Time of day items,  Next: Time zone items,  Prev: Calendar date items,  Up: Date input formats
7266
7267 7.3 Time of day items
7268 =====================
7269
7270 A "time of day item" in date strings specifies the time on a given day.
7271 Here are some examples, all of which represent the same time:
7272
7273      20:02:00.000000
7274      20:02
7275      8:02pm
7276      20:02-0500      # In EST (U.S. Eastern Standard Time).
7277
7278    More generally, the time of day may be given as
7279 `HOUR:MINUTE:SECOND', where HOUR is a number between 0 and 23, MINUTE
7280 is a number between 0 and 59, and SECOND is a number between 0 and 59
7281 possibly followed by `.' or `,' and a fraction containing one or more
7282 digits.  Alternatively, `:SECOND' can be omitted, in which case it is
7283 taken to be zero.  On the rare hosts that support leap seconds, SECOND
7284 may be 60.
7285
7286    If the time is followed by `am' or `pm' (or `a.m.' or `p.m.'), HOUR
7287 is restricted to run from 1 to 12, and `:MINUTE' may be omitted (taken
7288 to be zero).  `am' indicates the first half of the day, `pm' indicates
7289 the second half of the day.  In this notation, 12 is the predecessor of
7290 1: midnight is `12am' while noon is `12pm'.  (This is the zero-oriented
7291 interpretation of `12am' and `12pm', as opposed to the old tradition
7292 derived from Latin which uses `12m' for noon and `12pm' for midnight.)
7293
7294    The time may alternatively be followed by a time zone correction,
7295 expressed as `SHHMM', where S is `+' or `-', HH is a number of zone
7296 hours and MM is a number of zone minutes.  The zone minutes term, MM,
7297 may be omitted, in which case the one- or two-digit correction is
7298 interpreted as a number of hours.  You can also separate HH from MM
7299 with a colon.  When a time zone correction is given this way, it forces
7300 interpretation of the time relative to Coordinated Universal Time
7301 (UTC), overriding any previous specification for the time zone or the
7302 local time zone.  For example, `+0530' and `+05:30' both stand for the
7303 time zone 5.5 hours ahead of UTC (e.g., India).  This is the best way to
7304 specify a time zone correction by fractional parts of an hour.  The
7305 maximum zone correction is 24 hours.
7306
7307    Either `am'/`pm' or a time zone correction may be specified, but not
7308 both.
7309
7310 \1f
7311 File: tar.info,  Node: Time zone items,  Next: Day of week items,  Prev: Time of day items,  Up: Date input formats
7312
7313 7.4 Time zone items
7314 ===================
7315
7316 A "time zone item" specifies an international time zone, indicated by a
7317 small set of letters, e.g., `UTC' or `Z' for Coordinated Universal
7318 Time.  Any included periods are ignored.  By following a
7319 non-daylight-saving time zone by the string `DST' in a separate word
7320 (that is, separated by some white space), the corresponding daylight
7321 saving time zone may be specified.  Alternatively, a
7322 non-daylight-saving time zone can be followed by a time zone
7323 correction, to add the two values.  This is normally done only for
7324 `UTC'; for example, `UTC+05:30' is equivalent to `+05:30'.
7325
7326    Time zone items other than `UTC' and `Z' are obsolescent and are not
7327 recommended, because they are ambiguous; for example, `EST' has a
7328 different meaning in Australia than in the United States.  Instead,
7329 it's better to use unambiguous numeric time zone corrections like
7330 `-0500', as described in the previous section.
7331
7332    If neither a time zone item nor a time zone correction is supplied,
7333 time stamps are interpreted using the rules of the default time zone
7334 (*note Specifying time zone rules::).
7335
7336 \1f
7337 File: tar.info,  Node: Day of week items,  Next: Relative items in date strings,  Prev: Time zone items,  Up: Date input formats
7338
7339 7.5 Day of week items
7340 =====================
7341
7342 The explicit mention of a day of the week will forward the date (only
7343 if necessary) to reach that day of the week in the future.
7344
7345    Days of the week may be spelled out in full: `Sunday', `Monday',
7346 `Tuesday', `Wednesday', `Thursday', `Friday' or `Saturday'.  Days may
7347 be abbreviated to their first three letters, optionally followed by a
7348 period.  The special abbreviations `Tues' for `Tuesday', `Wednes' for
7349 `Wednesday' and `Thur' or `Thurs' for `Thursday' are also allowed.
7350
7351    A number may precede a day of the week item to move forward
7352 supplementary weeks.  It is best used in expression like `third
7353 monday'.  In this context, `last DAY' or `next DAY' is also acceptable;
7354 they move one week before or after the day that DAY by itself would
7355 represent.
7356
7357    A comma following a day of the week item is ignored.
7358
7359 \1f
7360 File: tar.info,  Node: Relative items in date strings,  Next: Pure numbers in date strings,  Prev: Day of week items,  Up: Date input formats
7361
7362 7.6 Relative items in date strings
7363 ==================================
7364
7365 "Relative items" adjust a date (or the current date if none) forward or
7366 backward.  The effects of relative items accumulate.  Here are some
7367 examples:
7368
7369      1 year
7370      1 year ago
7371      3 years
7372      2 days
7373
7374    The unit of time displacement may be selected by the string `year'
7375 or `month' for moving by whole years or months.  These are fuzzy units,
7376 as years and months are not all of equal duration.  More precise units
7377 are `fortnight' which is worth 14 days, `week' worth 7 days, `day'
7378 worth 24 hours, `hour' worth 60 minutes, `minute' or `min' worth 60
7379 seconds, and `second' or `sec' worth one second.  An `s' suffix on
7380 these units is accepted and ignored.
7381
7382    The unit of time may be preceded by a multiplier, given as an
7383 optionally signed number.  Unsigned numbers are taken as positively
7384 signed.  No number at all implies 1 for a multiplier.  Following a
7385 relative item by the string `ago' is equivalent to preceding the unit
7386 by a multiplier with value -1.
7387
7388    The string `tomorrow' is worth one day in the future (equivalent to
7389 `day'), the string `yesterday' is worth one day in the past (equivalent
7390 to `day ago').
7391
7392    The strings `now' or `today' are relative items corresponding to
7393 zero-valued time displacement, these strings come from the fact a
7394 zero-valued time displacement represents the current time when not
7395 otherwise changed by previous items.  They may be used to stress other
7396 items, like in `12:00 today'.  The string `this' also has the meaning
7397 of a zero-valued time displacement, but is preferred in date strings
7398 like `this thursday'.
7399
7400    When a relative item causes the resulting date to cross a boundary
7401 where the clocks were adjusted, typically for daylight saving time, the
7402 resulting date and time are adjusted accordingly.
7403
7404    The fuzz in units can cause problems with relative items.  For
7405 example, `2003-07-31 -1 month' might evaluate to 2003-07-01, because
7406 2003-06-31 is an invalid date.  To determine the previous month more
7407 reliably, you can ask for the month before the 15th of the current
7408 month.  For example:
7409
7410      $ date -R
7411      Thu, 31 Jul 2003 13:02:39 -0700
7412      $ date --date='-1 month' +'Last month was %B?'
7413      Last month was July?
7414      $ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!'
7415      Last month was June!
7416
7417    Also, take care when manipulating dates around clock changes such as
7418 daylight saving leaps.  In a few cases these have added or subtracted
7419 as much as 24 hours from the clock, so it is often wise to adopt
7420 universal time by setting the `TZ' environment variable to `UTC0'
7421 before embarking on calendrical calculations.
7422
7423 \1f
7424 File: tar.info,  Node: Pure numbers in date strings,  Next: Seconds since the Epoch,  Prev: Relative items in date strings,  Up: Date input formats
7425
7426 7.7 Pure numbers in date strings
7427 ================================
7428
7429 The precise interpretation of a pure decimal number depends on the
7430 context in the date string.
7431
7432    If the decimal number is of the form YYYYMMDD and no other calendar
7433 date item (*note Calendar date items::) appears before it in the date
7434 string, then YYYY is read as the year, MM as the month number and DD as
7435 the day of the month, for the specified calendar date.
7436
7437    If the decimal number is of the form HHMM and no other time of day
7438 item appears before it in the date string, then HH is read as the hour
7439 of the day and MM as the minute of the hour, for the specified time of
7440 day.  MM can also be omitted.
7441
7442    If both a calendar date and a time of day appear to the left of a
7443 number in the date string, but no relative item, then the number
7444 overrides the year.
7445
7446 \1f
7447 File: tar.info,  Node: Seconds since the Epoch,  Next: Specifying time zone rules,  Prev: Pure numbers in date strings,  Up: Date input formats
7448
7449 7.8 Seconds since the Epoch
7450 ===========================
7451
7452 If you precede a number with `@', it represents an internal time stamp
7453 as a count of seconds.  The number can contain an internal decimal
7454 point (either `.' or `,'); any excess precision not supported by the
7455 internal representation is truncated toward minus infinity.  Such a
7456 number cannot be combined with any other date item, as it specifies a
7457 complete time stamp.
7458
7459    Internally, computer times are represented as a count of seconds
7460 since an epoch--a well-defined point of time.  On GNU and POSIX
7461 systems, the epoch is 1970-01-01 00:00:00 UTC, so `@0' represents this
7462 time, `@1' represents 1970-01-01 00:00:01 UTC, and so forth.  GNU and
7463 most other POSIX-compliant systems support such times as an extension
7464 to POSIX, using negative counts, so that `@-1' represents 1969-12-31
7465 23:59:59 UTC.
7466
7467    Traditional Unix systems count seconds with 32-bit two's-complement
7468 integers and can represent times from 1901-12-13 20:45:52 through
7469 2038-01-19 03:14:07 UTC.  More modern systems use 64-bit counts of
7470 seconds with nanosecond subcounts, and can represent all the times in
7471 the known lifetime of the universe to a resolution of 1 nanosecond.
7472
7473    On most hosts, these counts ignore the presence of leap seconds.
7474 For example, on most hosts `@915148799' represents 1998-12-31 23:59:59
7475 UTC, `@915148800' represents 1999-01-01 00:00:00 UTC, and there is no
7476 way to represent the intervening leap second 1998-12-31 23:59:60 UTC.
7477
7478 \1f
7479 File: tar.info,  Node: Specifying time zone rules,  Next: Authors of get_date,  Prev: Seconds since the Epoch,  Up: Date input formats
7480
7481 7.9 Specifying time zone rules
7482 ==============================
7483
7484 Normally, dates are interpreted using the rules of the current time
7485 zone, which in turn are specified by the `TZ' environment variable, or
7486 by a system default if `TZ' is not set.  To specify a different set of
7487 default time zone rules that apply just to one date, start the date
7488 with a string of the form `TZ="RULE"'.  The two quote characters (`"')
7489 must be present in the date, and any quotes or backslashes within RULE
7490 must be escaped by a backslash.
7491
7492    For example, with the GNU `date' command you can answer the question
7493 "What time is it in New York when a Paris clock shows 6:30am on October
7494 31, 2004?" by using a date beginning with `TZ="Europe/Paris"' as shown
7495 in the following shell transcript:
7496
7497      $ export TZ="America/New_York"
7498      $ date --date='TZ="Europe/Paris" 2004-10-31 06:30'
7499      Sun Oct 31 01:30:00 EDT 2004
7500
7501    In this example, the `--date' operand begins with its own `TZ'
7502 setting, so the rest of that operand is processed according to
7503 `Europe/Paris' rules, treating the string `2004-10-31 06:30' as if it
7504 were in Paris.  However, since the output of the `date' command is
7505 processed according to the overall time zone rules, it uses New York
7506 time.  (Paris was normally six hours ahead of New York in 2004, but
7507 this example refers to a brief Halloween period when the gap was five
7508 hours.)
7509
7510    A `TZ' value is a rule that typically names a location in the `tz'
7511 database (http://www.twinsun.com/tz/tz-link.htm).  A recent catalog of
7512 location names appears in the TWiki Date and Time Gateway
7513 (http://twiki.org/cgi-bin/xtra/tzdate).  A few non-GNU hosts require a
7514 colon before a location name in a `TZ' setting, e.g.,
7515 `TZ=":America/New_York"'.
7516
7517    The `tz' database includes a wide variety of locations ranging from
7518 `Arctic/Longyearbyen' to `Antarctica/South_Pole', but if you are at sea
7519 and have your own private time zone, or if you are using a non-GNU host
7520 that does not support the `tz' database, you may need to use a POSIX
7521 rule instead.  Simple POSIX rules like `UTC0' specify a time zone
7522 without daylight saving time; other rules can specify simple daylight
7523 saving regimes.  *Note Specifying the Time Zone with `TZ': (libc)TZ
7524 Variable.
7525
7526 \1f
7527 File: tar.info,  Node: Authors of get_date,  Prev: Specifying time zone rules,  Up: Date input formats
7528
7529 7.10 Authors of `get_date'
7530 ==========================
7531
7532 `get_date' was originally implemented by Steven M. Bellovin
7533 (<smb@research.att.com>) while at the University of North Carolina at
7534 Chapel Hill.  The code was later tweaked by a couple of people on
7535 Usenet, then completely overhauled by Rich $alz (<rsalz@bbn.com>) and
7536 Jim Berets (<jberets@bbn.com>) in August, 1990.  Various revisions for
7537 the GNU system were made by David MacKenzie, Jim Meyering, Paul Eggert
7538 and others.
7539
7540    This chapter was originally produced by Franc,ois Pinard
7541 (<pinard@iro.umontreal.ca>) from the `getdate.y' source code, and then
7542 edited by K. Berry (<kb@cs.umb.edu>).
7543
7544 \1f
7545 File: tar.info,  Node: Formats,  Next: Media,  Prev: Date input formats,  Up: Top
7546
7547 8 Controlling the Archive Format
7548 ********************************
7549
7550 Due to historical reasons, there are several formats of tar archives.
7551 All of them are based on the same principles, but have some subtle
7552 differences that often make them incompatible with each other.
7553
7554    GNU tar is able to create and handle archives in a variety of
7555 formats.  The most frequently used formats are (in alphabetical order):
7556
7557 gnu
7558      Format used by GNU `tar' versions up to 1.13.25.  This format
7559      derived from an early POSIX standard, adding some improvements
7560      such as sparse file handling and incremental archives.
7561      Unfortunately these features were implemented in a way
7562      incompatible with other archive formats.
7563
7564      Archives in `gnu' format are able to hold file names of unlimited
7565      length.
7566
7567 oldgnu
7568      Format used by GNU `tar' of versions prior to 1.12.
7569
7570 v7
7571      Archive format, compatible with the V7 implementation of tar.  This
7572      format imposes a number of limitations.  The most important of them
7573      are:
7574
7575        1. The maximum length of a file name is limited to 99 characters.
7576
7577        2. The maximum length of a symbolic link is limited to 99
7578           characters.
7579
7580        3. It is impossible to store special files (block and character
7581           devices, fifos etc.)
7582
7583        4. Maximum value of user or group ID is limited to 2097151
7584           (7777777 octal)
7585
7586        5. V7 archives do not contain symbolic ownership information
7587           (user and group name of the file owner).
7588
7589      This format has traditionally been used by Automake when producing
7590      Makefiles.  This practice will change in the future, in the
7591      meantime, however this means that projects containing file names
7592      more than 99 characters long will not be able to use GNU `tar'
7593      1.21 and Automake prior to 1.9.
7594
7595 ustar
7596      Archive format defined by POSIX.1-1988 specification.  It stores
7597      symbolic ownership information.  It is also able to store special
7598      files.  However, it imposes several restrictions as well:
7599
7600        1. The maximum length of a file name is limited to 256
7601           characters, provided that the file name can be split at a
7602           directory separator in two parts, first of them being at most
7603           155 bytes long.  So, in most cases the maximum file name
7604           length will be shorter than 256 characters.
7605
7606        2. The maximum length of a symbolic link name is limited to 100
7607           characters.
7608
7609        3. Maximum size of a file the archive is able to accommodate is
7610           8GB
7611
7612        4. Maximum value of UID/GID is 2097151.
7613
7614        5. Maximum number of bits in device major and minor numbers is
7615           21.
7616
7617 star
7618      Format used by Jo"rg Schilling `star' implementation.  GNU `tar'
7619      is able to read `star' archives but currently does not produce
7620      them.
7621
7622 posix
7623      Archive format defined by POSIX.1-2001 specification.  This is the
7624      most flexible and feature-rich format.  It does not impose any
7625      restrictions on file sizes or file name lengths.  This format is
7626      quite recent, so not all tar implementations are able to handle it
7627      properly.  However, this format is designed in such a way that any
7628      tar implementation able to read `ustar' archives will be able to
7629      read most `posix' archives as well, with the only exception that
7630      any additional information (such as long file names etc.) will in
7631      such case be extracted as plain text files along with the files it
7632      refers to.
7633
7634      This archive format will be the default format for future versions
7635      of GNU `tar'.
7636
7637
7638    The following table summarizes the limitations of each of these
7639 formats:
7640
7641 Format  UID            File Size      File Name      Devn
7642 -------------------------------------------------------------------- 
7643 gnu     1.8e19         Unlimited      Unlimited      63
7644 oldgnu  1.8e19         Unlimited      Unlimited      63
7645 v7      2097151        8GB            99             n/a
7646 ustar   2097151        8GB            256            21
7647 posix   Unlimited      Unlimited      Unlimited      Unlimited
7648
7649    The default format for GNU `tar' is defined at compilation time.
7650 You may check it by running `tar --help', and examining the last lines
7651 of its output.  Usually, GNU `tar' is configured to create archives in
7652 `gnu' format, however, future version will switch to `posix'.
7653
7654 * Menu:
7655
7656 * Compression::                 Using Less Space through Compression
7657 * Attributes::                  Handling File Attributes
7658 * Portability::                 Making `tar' Archives More Portable
7659 * cpio::                        Comparison of `tar' and `cpio'
7660
7661 \1f
7662 File: tar.info,  Node: Compression,  Next: Attributes,  Up: Formats
7663
7664 8.1 Using Less Space through Compression
7665 ========================================
7666
7667 * Menu:
7668
7669 * gzip::                        Creating and Reading Compressed Archives
7670 * sparse::                      Archiving Sparse Files
7671