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