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