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