home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tar-1.11.8-bin.lha / info / tar.info-1 (.txt) < prev    next >
GNU Info File  |  1996-10-12  |  49KB  |  993 lines

  1. This is Info file tar.info, produced by Makeinfo-1.64 from the input
  2. file /ade-src/fsf/tar/doc/tar.texinfo.
  3. START-INFO-DIR-ENTRY
  4. * tar: (tar).            Making tape (or disk) archives.
  5. END-INFO-DIR-ENTRY
  6.    This file documents GNU `tar', a utility used to store, backup, and
  7. transport files.
  8.    Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20. File: tar.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  21. GNU tar
  22. *******
  23.    This file documents `tar', a utility used to store, backup, and
  24. transport files.  It is a rudimentary documentation for the GNU tape
  25. (or disk) archiver.  It covers the release 1.11.8.
  26.    This document has been quickly assembled from random notes and
  27. sources.  I will of course accept documentation bug reports, but please
  28. do not torture yourself into systematically reporting all inadequacies
  29. for unrevised nodes.
  30. * Menu:
  31. * Introduction::
  32. * Tutorial::
  33. * Invoking tar::
  34. * Basic tar Operations::
  35. * Specifying Names to tar::
  36. * Being Careful::
  37. * Format Control::
  38. * Media::
  39. * Backups and Restoration::
  40. * Date input formats::
  41. * Archive Format::
  42. * Index::
  43.  -- The Detailed Node Listing --
  44. Introduction
  45. * What tar Does::
  46. * Authors::
  47. * Bug reports::
  48. * Support::
  49. Support considerations
  50. * Stability::
  51. * Rewriting::
  52. * Why maintaining::
  53. * MSDOS::
  54. Tutorial Introduction to `tar'
  55. * How to Create Archives::
  56. * How to List Archives::
  57. * How to Extract Members from an Archive::
  58. * How to Add Files to Existing Archives::
  59. * How to Delete Members from Archives::
  60. How to Create Archives
  61. * Creating Archives of Files bis::
  62. * Using tar in Verbose Mode bis::
  63. * How to Archive Directories::
  64. * Creating an Archive of a Subdirectory bis::
  65. * Compare bis::
  66. * Using Compare from the Superior Directory bis::
  67. How to Archive Directories
  68. * Creating an Archive of a Subdirectory bis::
  69. How to List Archives
  70. * Listing files in an archive bis::
  71. * Getting Additional File Information bis::
  72. * List A Specific File in an Archive bis::
  73. * Listing the Contents of a Stored Directory ter::
  74. How to Extract Members from an Archive
  75. * Extracting Files bis::
  76. * Extracting Files from an Archive ter::
  77. * Extracting Specific Files ter::
  78. * Extracting Directories ter::
  79. How to Add Files to Existing Archives
  80. * Append bis::
  81. * Update bis::
  82. * Concatenate bis::
  83. Invoking GNU `tar'
  84. * Synopsis::
  85. * Option Styles::
  86. * Options::
  87. Many Styles for Options
  88. * Mnemonic Options::
  89. * Short Options::
  90. * Old Options::
  91. * Mixing Styles::
  92. All Available Options
  93. * Device Options::
  94. * Blocking Options::
  95. * Classification Options::
  96. Basic `tar' Operations
  97. * Creating a New Archive::
  98. * Adding to an Existing Archive::
  99. * Updating an Archive::
  100. * Combining Archives::
  101. * Removing Archive Members::
  102. * Listing Archive Members::
  103. * Extracting Archive Members::
  104. * Comparing Archives Members with Files::
  105. * Matching Format Parameters::
  106. Extracting Archive Members
  107. * Archive Reading Options::
  108. * File Writing Options::
  109. * Scarce Disk Space::
  110. Specifying Names to `tar'
  111. * Changing the Archive Name::
  112. * Characteristics::
  113. * Selection Options::
  114. Selecting Files by Characteristic
  115. * Reading Names from a File::
  116. * Excluding Some Files::
  117. * Operating Only on New Files::
  118. * Crossing Filesystem Boundaries::
  119. Local file selection
  120. * Changing Directory::
  121. * Absolute File Names::
  122. Being Even More Careful
  123. * Documentation::
  124. * Checking Progress::
  125. * Interactive Operation::
  126. * Write Verification::
  127. * Comparing::
  128. * Portability::
  129. * Write Protection::
  130. Making `tar' Archives More Portable
  131. * Portable Names::
  132. * Symbolic Links::
  133. * Old V7 and POSIX::
  134. * Checksumming Problems::
  135. Controlling the Archive Format
  136. * Attributes Options::
  137. * Type Options::
  138. * Compression::
  139. * Special Options for Archiving::
  140. * Archive Structure::
  141. * Modifiers Options::
  142. Using Less Space through Compression
  143. * Compressed Archives::
  144. * Dealing with Compressed Archives::
  145. * Sparse Files::
  146. Tapes and Other Archive Media
  147. * Device::
  148. * Blocking::
  149. * Many::
  150. * Using Multiple Tapes::
  151. * Archive Label::
  152. Blocking
  153. * Format Variations::
  154. * Blocking Factor::
  155. Many archives on one tape
  156. * Tape Positioning::
  157. * mt::
  158. Using Multiple Tapes
  159. * Multi-Volume Archives::
  160. * Tape Files::
  161. Performing Backups and Restoring Files
  162. * Full Dumps::
  163. * Inc Dumps::
  164. * incremental and listed-incremental::
  165. * Backup Levels::
  166. * Backup Parameters::
  167. * Scripted Backups::
  168. * Scripted Restoration::
  169. Setting Parameters for Backups and Restoration
  170. * backup-specs example::
  171. * Script Syntax::
  172. Date input formats
  173. * General date syntax::
  174. * Calendar date item::
  175. * Time of day item::
  176. * Timezone item::
  177. * Day of week item::
  178. * Relative item in date strings::
  179. * Pure numbers in date strings::
  180. * Authors of getdate::
  181. Format of `tar' archives
  182. * Standard::
  183. * Extensions::
  184. * cpio::
  185. File: tar.info,  Node: Introduction,  Next: Tutorial,  Prev: Top,  Up: Top
  186. Introduction
  187. ************
  188.    This chapter introduces of a few words which will recur all over
  189. this manual, like "archive", "member", "name", "unpack", etc.  It then
  190. explains who wrote GNU `tar' and its documentation, and says where to
  191. send bug reports or comments.
  192. * Menu:
  193. * What tar Does::
  194. * Authors::
  195. * Bug reports::
  196. * Support::
  197. File: tar.info,  Node: What tar Does,  Next: Authors,  Prev: Introduction,  Up: Introduction
  198. What `tar' Does
  199. ===============
  200.    The `tar' program is used to create and manipulate `tar' archives.
  201. An "archive" is a single file which contains within it the contents of
  202. many files.  In addition, the archive identifies the names of the
  203. files, their owner, and so forth.  (Archives record access permissions,
  204. user and group, size in bytes, and last modification time.  Some
  205. archives also record the file names in each archived directory, as well
  206. as other file and directory information.)
  207.    The files inside an archive are called "members".  Within this
  208. manual, we use the term "file" to refer only to files accessible in the
  209. normal ways (by `ls', `cat', and so forth), and the term "members" to
  210. refer only to the members of an archive.  Similarly, a "file name" is
  211. the name of a file, as it resides in the filesystem, and a "member
  212. name" is the name of an archive member within the archive.
  213.    Initially, `tar' archives were used to store files conveniently on
  214. magnetic tape.  The name `tar' comes from this use; it stands for:
  215. `t'ape `ar'chiver.  Despite the utility's name, `tar' can direct its
  216. output to any available device, as well as store it in a file or direct
  217. it to another program via a pipe.  `tar' may even access, as archives,
  218. remote devices or files.
  219.    You can use `tar' archives in many ways.  We want to stress a few of
  220. them: storage, backup or transportation.
  221. Storage
  222.      Often, `tar' archives are used to store related files for
  223.      convenient file transfer over a network.  For example, the GNU
  224.      Project distributes its software bundled into `tar' archives, so
  225.      that all the files relating to a particular program (or set of
  226.      related programs) can be transferred as a single unit.
  227.      A magnetic tape can store several files in sequence, but has no
  228.      names for them, just relative position on the tape.  A `tar'
  229.      archive or something like it is one way to store several files on
  230.      one tape and retain their names.  Even when the basic transfer
  231.      mechanism can keep track of names, as FTP can, the nuisance of
  232.      handling multiple files, directories, and multiple links, makes
  233.      `tar' archives an attractive method.
  234.      Archive files are also used for long-term storage, which you can
  235.      think of as transportation from one time to another.
  236. Backup
  237.      Because the archive created by `tar' is capable of preserving file
  238.      information and directory structure, `tar' is commonly used for
  239.      performing full and incremental backups of disks, putting all
  240.      together bunch of files possibly pertaining to many users and
  241.      different projects, to secure against accidental destruction of
  242.      those disks.
  243.      The GNU version of `tar' has special features that allow it to be
  244.      used to make incremental and full dumps of all the files in a
  245.      filesystem.
  246. Transportation
  247.      Archive files can be used for transporting a group of files from
  248.      one system to another: put all relevant files into an archive on
  249.      one computer system, transfer the archive to another, and extract
  250.      the contents there.  The basic transfer medium might be magnetic
  251.      tape, Internet FTP, or even electronic mail (though you must
  252.      encode the archive with `uuencode' or some functional equivalent
  253.      in order to transport it properly by mail).  Both machines do not
  254.      have to use the same operating system, as long as they both
  255.      support the `tar' program.
  256.      Piping one `tar' to another is an easy way to copy a directory's
  257.      contents from one disk to another, while preserving the dates,
  258.      modes, owners and link structure of all the files therein.  `tar'
  259.      is also ideal for transferring directories over networks.  We
  260.      sometimes see a copy of `tar' packing many files into one archive
  261.      on one machine, and sending the produced archive over a pipe over
  262.      the network to another copy of `tar' on another machine, reading
  263.      its archive from the pipe and unpacking all files there.
  264.    The `tar' program provides the ability to create `tar' archives, as
  265. well as for various other kinds of manipulation.  For example, you can
  266. use `tar' on previously created archives to extract files, to store
  267. additional files, or to update or list files already stored.  The term
  268. "extraction" is used to refer to the process of copying an archive
  269. member into a file in the filesystem.  One might speak of extracting a
  270. single member.  Extracting all the members of an archive is often
  271. called extracting the archive.  Also, the term "unpack" is used to
  272. refer to the extraction of many or all the members of an archive.
  273.    Conventionally, `tar' archives are given names ending with `.tar'.
  274. This is not necessary for `tar' to operate properly, but this manual
  275. follows the convention in order to get the reader used to seeing it.
  276.    Occasionally, `tar' archives are referred to as `tar' files, archive
  277. members are referred to as files, or entries.  For people familiar with
  278. the operation of `tar', this causes no difficulty.  However, this
  279. manual consistently uses the terminology above in referring to archives
  280. and archive members, to make it easier to learn how to use `tar'.
  281. File: tar.info,  Node: Authors,  Next: Bug reports,  Prev: What tar Does,  Up: Introduction
  282. GNU `tar' Authors
  283. =================
  284.    GNU `tar' was originally written by John Gilmore, and modified by
  285. many people.  The GNU enhancements were written by Jay Fenlason, and
  286. the whole package has been further maintained by Michael Bushnell, then
  287. Franc,ois Pinard, with the help of numerous and kind users.  I wish to
  288. stress that `tar' is somewhat a collective work, and owe much to all
  289. those people who reported problems, offerred solutions and other
  290. insights, or shared their thoughts and suggestions.  Even if we lost
  291. track of many of those contributors, a partial list can be found in the
  292. `THANKS' file from the GNU `tar' distribution.
  293.    Jay Fenlason put together a draft of a GNU `tar' manual, also
  294. borrowing notes from the original man page from John Gilmore, this
  295. draft has been distributed in `tar' versions 1.04 (or even before?)
  296. through 1.10, then withdrawn in version 1.11.  Michael Bushnell and Amy
  297. Gorin worked at a tutorial and manual for GNU `tar', and left a few
  298. unpublished versions of each.  For version 1.11.8, Franc,ois Pinard put
  299. together a new manual by grabbing from all these sources and merging
  300. them in a single manual.
  301.    I heard that there is another manual in the works, by another team,
  302. which should say everything about archives and related utilities, and
  303. which will surely be nicer than this one.  In the meantime, please
  304. consider this manual is a placeholder for `tar' option list and a few
  305. random notes the maintainer wants to save somewhere, so users can read
  306. them.  I wish GNU `tar' users will be happier with this imperfect
  307. manual than with no documentation at all.
  308. File: tar.info,  Node: Bug reports,  Next: Support,  Prev: Authors,  Up: Introduction
  309. Reporting bugs or suggestions
  310. =============================
  311.    Please report problems or suggestions about this program to
  312. `bug-gnu-utils@prep.ai.mit.edu'.  You may also write directly, and less
  313. officially, to `pinard@iro.umontreal.ca'.  There is a lot of mail
  314. flowing about `tar', and some accumulated in the past years.  You might
  315. expect a quick acknowledgement of your invoices, but the proper
  316. handling of your reports may be delayed for a long while.
  317.    Many nodes of this document have not been revised much, these all
  318. start with a little comment telling so.  I accept documentation bug
  319. reports, of course.  But please do not torture yourself into
  320. systematically reporting all inadequacies for the unrevised nodes of
  321. this document, unless you really feel like revising them.
  322. File: tar.info,  Node: Support,  Prev: Bug reports,  Up: Introduction
  323. Support considerations
  324. ======================
  325.    This informal appendix is for the maintainer to share a few words
  326. and thoughts, while considering GNU `tar' support.
  327. * Menu:
  328. * Stability::
  329. * Rewriting::
  330. * Why maintaining::
  331. * MSDOS::
  332. File: tar.info,  Node: Stability,  Next: Rewriting,  Prev: Support,  Up: Support
  333. Stability of GNU `tar'
  334. ----------------------
  335.    User reports mainly fall in three categories: portability problems,
  336. execution bugs, and requests for enhancements.  For 1.11.X, the
  337. emphasis has been on solving portability problems, then trying to make
  338. GNU `tar' more solid.  Enhancements have fairly low priority, yet I
  339. sometime slip one in just for taking a kind of rest :-).
  340.    Many bugs have been corrected since 1.11.2.  If you are curious,
  341. glance through ChangeLog.  I had only very few reports for things that
  342. *might* be new bugs not present in 1.11.2.  If you are really curious,
  343. and have access to the FSF machines, see `/gd/gnu/tar/rmail/' hierarchy
  344. for all reports.  Subdirectories `0', `1', `2' and `3' represent
  345. decreasing levels in priority.  Most problems in there were reported
  346. against 1.10, 1.11 or 1.11.2 and still exist.  The only thing I have
  347. consciously broken between 1.11.2 and 1.11.5 is `--record-number'
  348. (`-R'), because I wanted some modification to be done to
  349. `gnulib/error.c', which is outside my control.  This modification is
  350. now done, but I did not revisit this area yet.
  351.    Here is my candid opinion.  GNU `tar' has many areas of
  352. unreliability.  See `BACKLOG' for the horrorful picture of the
  353. situation.  Yet, for most users and usages, GNU `tar' looks very
  354. dependable.  For me as a mere user, GNU `tar' did not give problems in
  355. years.  And I think it offers a lot of functionality.  Many problems
  356. have been solved since 1.11.2, even if true that many more remain to be
  357. solved.  I'm not discouraged myself and feel positive about maintaining
  358. it, simply because when I bite, that usually lasts for quite long.  I
  359. might not have all the time I would want, but I surely have good will
  360. and am happily surrounded by many collaborating pretesters.  So, I
  361. still think GNU `tar' is on the winning side in the long run.
  362. File: tar.info,  Node: Rewriting,  Next: Why maintaining,  Prev: Stability,  Up: Support
  363. Should we rewrite the thing?
  364. ----------------------------
  365.    Working in `tar' sources is not always pleasurable.  The problem is
  366. that `tar' sources are very fragile.  Just cleaning around breaks
  367. things.  The current sequence of prereleases is for slowly trying to
  368. solidify it, so `tar' becomes more maintainable.  I think that the
  369. ugliness of sources could be corrected to a certain extent, too.
  370.    A few efforts to replace GNU `tar' have been done already and it
  371. seems that all failed so far.  A toy program, for me, is another kind
  372. of failure.  I think people underestimate the number of portability
  373. problems such a program can raise.  This is not only a matter of
  374. programming style, there is really a wide variability in systems out
  375. there.  GNU `tar' has a long history, met a rich variety of porting
  376. problems, machine peculiarities, system idiosyncrasies, which are
  377. unrelated to programming style.  My own opinion is that we cannot
  378. dismiss all the experience gleaned along the years, and saved (if not
  379. hidden) in GNU `tar' sources, pretending to start anew, from scratch.
  380.    Even if a new program replacing GNU `tar' would be marvelous, GNU
  381. `tar' stalled for a few years waiting for such a program, and we are
  382. now faced to nothing, with hundreds of user reports to catch on.  We
  383. need a working archiver *now*, and cannot live on promises.  Any new
  384. program will take hundreds of user reports, and many years, to
  385. stabilize enough to become a plausible `tar' replacement.  I rather
  386. plan to clean up GNU `tar'.  This alone is a big task for me, because
  387. GNU `tar' coding is not ideal, and I have to find ways to transform it
  388. slowly, while having it fully working at all times.
  389. File: tar.info,  Node: Why maintaining,  Next: MSDOS,  Prev: Rewriting,  Up: Support
  390. Why maintaining it?
  391. -------------------
  392.    I confess that I am a little afraid of `tar' maintainance.  It is
  393. difficult for many reasons, the first tree being more evident than the
  394. others:
  395.    * the algorithmic design was initially oriented for machines having
  396.      very small memory, it was later much adapted for new features
  397.      without doing everything necessary for the whole to stay clean;
  398.    * the wide visibility of `tar' forces many stunts at portability;
  399.    * GNU `tar' has to be sensitive to file systems and device variance.
  400.    * GNU central has been seduced by some users promising to write
  401.      wonderful `tar' replacements, which never came, so development has
  402.      been put aside for years, while bug reports accumulated;
  403.    * the `tar' manual has been withdrawn, promising users a fine
  404.      replacement for it, so raising their expectations;
  405.    * maintenance was once split between four maintainers (one for
  406.      `tar', one for `mt', another for scripts, and a team for
  407.      documentation), and also, `rtapelib.[ch]' from `tar' is used in
  408.      `cpio', and synchronisation has not always been easy.
  409.    However, even if difficult, I do feel like doing a careful cleanup,
  410. so `tar' would become less painful to maintain after a while (and less
  411. subject to criticism).  And besides, I'm surrounded by a marvelous team
  412. of pretesters and by many other collaborating users, which I should
  413. learn to serve better.  Getting more experience with maintainance in
  414. GNU, I hope being careful enough modifying `tar' so not hurting users
  415. too much, being aware that `tar' is a sensitive product in GNU.  Once
  416. cleaned up, I might be happy to return `tar' maintainance to someone
  417. else...
  418.    `tar' requires more work alone that all my other things together,
  419. and I have to resist being swallowed whole in it.  This resistance
  420. makes `tar' development somewhat slower.  Sorry!
  421. File: tar.info,  Node: MSDOS,  Prev: Why maintaining,  Up: Support
  422. MSDOS and other systems?
  423. ------------------------
  424.    GNU does not necessarily support non-UNIX systems, that is to say,
  425. MSDOS is not supported.  It is very true that ports can sometimes be
  426. very intrusive in the sources, cluttering them significantly with
  427. conditionals and extra code, and distract GNU maintainers from the main
  428. development line.
  429.    However, a special argument might be made for `tar'.  Both `tar' and
  430. `gzip' are the required tools for getting something out of the GNU
  431. archives, `tar' should be more opened to ports than the GNU rule
  432. states.  Jean-loup did a tremendous job at porting `gzip' on smaller
  433. systems.  It would be comfortable that a few other GNU tools be
  434. available on MSDOS and others, among which `tar'.  These ports for
  435. `tar' have theoretically no priority at all.  Nevertheless, a port is
  436. interesting, because `tar' is so central in GNU distributions, and
  437. `gzip' is already ported.
  438.    Some porting efforts have been done in the past.  There are traces of
  439. a few exchanges on this subject in `BACKLOG'.  GNU `tar' sources have
  440. been modified a lot recently at a cosmetic level, and I would certainly
  441. have a hard time integrating diffs provided by someone else.  If people
  442. want porting `tar' to MSDOS or other non-UNIX systems, they should be
  443. committed in supporting their ports after the fact, as I cannot do it
  444. myself.
  445. File: tar.info,  Node: Tutorial,  Next: Invoking tar,  Prev: Introduction,  Up: Top
  446. Tutorial Introduction to `tar'
  447. ******************************
  448.    This chapter guides you through some basic examples of `tar'
  449. operations.  If you already know how to use some other version of
  450. `tar', then you probably don't need to read this chapter.  This chapter
  451. omits complicated details about many of the ways `tar' works.  See
  452. later chapters for full information.
  453.    Before proceeding further with this tutorial chapter, be sure you
  454. understand already and clearly what is meant by "archive" and "archive
  455. member".
  456. FIXME: xref What tar Does
  457.    This chapter guides you through some basic examples of `tar'
  458. operations.  In the examples, the lines you should type are preceded by
  459. a `%', which is a typical shell prompt.  We use mnemonic forms of
  460. operations and options in the examples, and in discussions in the text,
  461. but short forms produce the same result.
  462.    Most of the options to `tar' come in both long forms and short
  463. forms.  The options described in this tutorial have the following
  464. abbreviations (except `--delete', which has no shorthand form):
  465. `--create'
  466.      `-c'
  467. `--list'
  468.      `-t'
  469. `--extract'
  470.      `-x'
  471. `--append'
  472.      `-r'
  473. `--verbose'
  474.      `-v'
  475. `--file=ARCHIVE-NAME'
  476.      `-f ARCHIVE-NAME'
  477.    These options make typing long `tar' commands easier.  For example,
  478. instead of typing
  479.      tar --create --file=/tmp/afiles.tar --verbose apple angst asparagus
  480.    you can type
  481.      tar -c -f /tmp/afiles.tar -v apple angst asparagus
  482.    For more information on option syntax,
  483. FIXME: ref Invoking tar
  484.    .  In discussions in the text, when we present some mnemonic option,
  485. we also give the corresponding short option within parentheses.
  486. * Menu:
  487. * How to Create Archives::
  488. * How to List Archives::
  489. * How to Extract Members from an Archive::
  490. * How to Add Files to Existing Archives::
  491. * How to Delete Members from Archives::
  492. File: tar.info,  Node: How to Create Archives,  Next: How to List Archives,  Prev: Tutorial,  Up: Tutorial
  493. How to Create Archives
  494. ======================
  495.      *(This message will disappear, once this node revised.)*
  496.    To create a new archive, use the `--create' (`-c') option to `tar'.
  497. You can use options to specify the name and format of the archive (as
  498. well as other characteristics), and you can use file name arguments to
  499. specify which files and directories are to be put in the archive.
  500. FIXME: xref Creating
  501.    , for more information about the `--create' (`-c') operation.
  502.    To create a new archive, use the `--create' (`-c') option to `tar'.
  503. You should generally use the `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME')
  504. option to specify the name the `tar' archive will have.  Then specify
  505. the names of the files you wish to place in the new archive.  For
  506. example, to place the files `apple', `angst', and `asparagus' into an
  507. archive named `afiles.tar', use the following command:
  508.      tar --create --file=afiles.tar apple angst asparagus
  509.    The order of the arguments is not important when using mnemonic
  510. option style.  You could also say:
  511.      tar apple --create angst --file=afiles.tar asparagus
  512.    This order is harder to understand however.  In this manual, we will
  513. list the arguments in a reasonable order to make the commands easier to
  514. understand, but you can type them in any order you wish.
  515.    If you don't specify the names of any files to put in the archive,
  516. then `tar' will create an empty archive.  So, the following command
  517. will create an archive with nothing in it:
  518.      tar --create --file=empty-archive.tar
  519.    Whenever you use `--create' (`-c'), `tar' will erase the current
  520. contents of the file named by `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME')
  521. if it exists.  To add files to an existing archive, you need to use a
  522. different option.
  523. FIXME: xref Adding to Archives, for information on how to do this.
  524.    When an archive is created through `--create' (`-c'), the member
  525. names of the members of the archive are exactly the same as the file
  526. names as you typed them in the `tar' command.  So, the member names of
  527. `afiles' (as created by the first example above) are `apple', `angst',
  528. and `asparagus'.  However, suppose an archive were created with this
  529. command:
  530.      tar --create --file=bfiles.tar ./balloons baboon ./bodacious
  531.    Then, the three files `balloons', `baboon', and `bodacious' would
  532. get placed in the archive (because `./' is a synonym for the current
  533. directory), but their member names would be `./balloons', `baboon', and
  534. `./bodacious'.
  535.    If you want to see the progress of `tar' as it writes files into the
  536. archive, you can use the `--verbose' (`-v') option.
  537.    If one of the files named with `--create' (`-c') is a directory, then
  538. the operation of `tar' is more complicated.
  539. FIXME: xref Tar and Directories,
  540. FIXME: the last section of this tutorial, for more information.
  541.    If you don't specify the `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME')
  542. option, then `tar' will use a default.  Usually this default is some
  543. physical tape drive attached to your machine.  If there is no tape
  544. drive attached, or the default is not meaningful, then `tar' will print
  545. an error message.  This error message might look roughly like one of
  546. the following:
  547.      tar: can't open /dev/rmt8 : No such device or address
  548.      tar: can't open /dev/rsmt0 : I/O error
  549.    If you get an error like this, mentioning a file you didn't specify
  550. (`/dev/rmt8' or `/dev/rsmt0' in the examples above), then `tar' is
  551. using a default value for `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  552. You should generally specify a `--file=ARCHIVE-NAME' (`-f
  553. ARCHIVE-NAME') argument whenever you use `tar', rather than relying on
  554. a default.
  555.    To create a new archive, use the `--create' (`-c') option to `tar'.
  556. You can use options to specify the name and format of the archive (as
  557. well as other characteristics), and you can use file name arguments to
  558. specify which files to put in the archive.  If you don't use any
  559. options or file name arguments, `tar' will use default values.
  560. FIXME: xref Creating Example
  561.    , for more information about the `--create' (`-c') option.
  562. * Menu:
  563. * Creating Archives of Files bis::
  564. * Using tar in Verbose Mode bis::
  565. * How to Archive Directories::
  566. * Creating an Archive of a Subdirectory bis::
  567. * Compare bis::
  568. * Using Compare from the Superior Directory bis::
  569. File: tar.info,  Node: Creating Archives of Files bis,  Next: Using tar in Verbose Mode bis,  Prev: How to Create Archives,  Up: How to Create Archives
  570. Creating Archives of Files
  571. --------------------------
  572.      *(This message will disappear, once this node revised.)*
  573.    This example shows you how to create an archive file in your working
  574. directory containing other files in the same directory.  The three
  575. files you archive in this example are called `blues', `folk', and
  576. `jazz'.  The archive file is called `records'.  While the archive in
  577. this example is written to the file system, it could also be written to
  578. tape.  (If you want to follow along with this and future examples,
  579. create a practice subdirectory containing files with these names.  To
  580. create the directory, type `mkdir practice' at the system prompt.  You
  581. can create the files using a text editor, such as `emacs').
  582.    While in the directory containing the files you want to archive, list
  583. the directory's contents.
  584.    Type:
  585.      % cd practice
  586.      % ls
  587. The system responds:
  588.      blues    folk    jazz
  589.      %
  590. This is to check that the files to be archived do in fact exist in the
  591. working directory, and to check that the archive name you have chosen
  592. isn't already in use.  If it is, `tar' will overwrite the old archive
  593. and its contents will be lost.
  594.    Then,
  595.    * Create a new archive by giving `--create' (`-c') to `tar'.
  596.    * Explicitly name the archive file being
  597.      created--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').  If you don't
  598.      use this option `tar' will write the archive to the default
  599.      storage device, which varies from system to system.
  600.    * Specify which files to put into the archive.  If you don't specify
  601.      any FILE NAME arguments, `tar' will archive everything in the
  602.      working directory.
  603. Type:
  604.      % tar --create --file=records blues folk jazz
  605. If you now list the contents of the working directory (`ls'), you will
  606. find the archive file listed as well as the files you saw previously.
  607.      % ls
  608.      blues folk jazz records
  609.      %
  610.    This example shows you how to create an archive file in the working
  611. directory containing other files in the working directory.  The three
  612. files you archive in this example are called `blues', `folk', and
  613. `jazz'.  The archive file is called `records'.  While the archive in
  614. this example is written to the file system, it could also be written to
  615. any other device.
  616.    (If you want to follow along with this and future examples, create a
  617. directory called `practice' containing files called `blues', `folk' and
  618. `jazz'.  To create the directory, type `mkdir practice' at the system
  619. prompt.  It will probably be easiest to create the files using a text
  620. editor, such as Emacs.)
  621.    First, change into the directory containing the files you want to
  622. archive:
  623.      % cd practice
  624.    `~/practice' is now your working directory.
  625.    Then, check that the files to be archived do in fact exist in the
  626. working directory, and make sure there isn't already a file in the
  627. working directory with the archive name you intend to use.  If you
  628. specify an archive file name that is already in use, `tar' will
  629. overwrite the old file and its contents will be lost.
  630.    To list the names of files in the working directory, type:
  631.      % ls
  632.    The system responds:
  633.      blues   folk    jazz
  634.      %
  635.    Then,
  636.    * Create a new archive by giving the `--create' (`-c') option to
  637.      `tar'.
  638.    * Explicitly name the archive file being
  639.      created--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').  If you don't
  640.      use this option `tar' will write the archive to the default
  641.      storage device, which varies from system to system.
  642.      FIXME: this syntax may change.  OK now--check before printing
  643.      `tar' interprets archive file names relative to the working
  644.      directory.  Make sure you have write access to the working
  645.      directory before using `tar'.
  646.    * Specify which files to put into the archive (`tar' interprets file
  647.      names relative to the working directory).  If you don't use any
  648.      NAME arguments, `tar' will archive everything in the working
  649.      directory.
  650.    Type:
  651.      % tar --create --file=records blues folk jazz
  652.    If you now list the contents of the working directory (`ls'), you
  653. will find the archive file listed as well as the files you saw
  654. previously.
  655.      % ls
  656.      blues folk jazz records
  657.      %
  658. File: tar.info,  Node: Using tar in Verbose Mode bis,  Next: How to Archive Directories,  Prev: Creating Archives of Files bis,  Up: How to Create Archives
  659. Using `tar' in Verbose Mode
  660. ---------------------------
  661.      *(This message will disappear, once this node revised.)*
  662.    If you include the `--verbose' (`-v') option on the command line,
  663. `tar' will list the files it is acting on as it is working.  The
  664. example above in verbose mode would be:
  665.      % tar --create --file=records --verbose blues folk jazz
  666.      blues
  667.      folk
  668.      jazz
  669. The first line, which is preceeded by a `%', is the command line.  The
  670. lines after the first line are generated by `tar' as it works.  In the
  671. following examples we usually use verbose mode, though it is almost
  672. never required.
  673.    If you include the `--verbose' (`-v') option on the command line,
  674. `tar' will list the files it is acting on as it is working. In verbose
  675. mode, the creation example above would appear as:
  676.      % tar --create --file=records --verbose blues folk jazz
  677.      blues
  678.      folk
  679.      jazz
  680.    The first line is the command typed in by the user.  The remaining
  681. lines are generated by `tar'.  In the following examples we usually use
  682. verbose mode, though it is almost never required.
  683. File: tar.info,  Node: How to Archive Directories,  Next: Creating an Archive of a Subdirectory bis,  Prev: Using tar in Verbose Mode bis,  Up: How to Create Archives
  684. How to Archive Directories
  685. --------------------------
  686.      *(This message will disappear, once this node revised.)*
  687.    When the names of files or members specify directories, the
  688. operation of `tar' is more complex.  Generally, when a directory is
  689. named, `tar' also operates on all the contents of the directory,
  690. recursively.  Thus, to `tar', the file name `/' names the entire file
  691. system.
  692.    To archive the entire contents of a directory, use `--create' (`-c')
  693. or `--append' (`-r') as usual, and specify the name of the directory.
  694. For example, to archive all the contents of the current directory, use
  695. `tar --create --file=ARCHIVE-NAME .'.  Doing this will give the archive
  696. members names starting with `./'.  To archive the contents of a
  697. directory named `foodir', use `tar --create --file=ARCHIVE-NAME
  698. foodir'.  In this case, the member names will all start with `foodir/'.
  699.    If you give `tar' a command such as `tar --create --file=foo.tar .',
  700. it will report `tar: foo.tar is the archive; not dumped'.  This happens
  701. because the archive `foo.tar' is created before putting any files into
  702. it.  Then, when `tar' attempts to add all the files in the directory
  703. `.' to the archive, it notices that the file `foo.tar' is the same as
  704. the archive, and skips it.  (It makes no sense to put an archive into
  705. itself.)  GNU `tar' will continue in this case, and create the archive
  706. as normal, except for the exclusion of that one file.  Other versions
  707. of `tar', however, are not so clever, and will enter an infinite loop
  708. when this happens, so you should not depend on this behavior.  In
  709. general, make sure that the archive is not inside a directory being
  710. dumped.
  711.    When extracting files, you can also name directory archive members on
  712. the command line.  In this case, `tar' extracts all the archive members
  713. whose names begin with the name of the directory.  As usual, `tar' is
  714. not particularly clever about interpreting member names.  The command
  715. `tar --extract --file=ARCHIVE-NAME .' will not extract all the contents
  716. of the archive, but only those members whose member names begin with
  717. `./'.
  718. * Menu:
  719. * Creating an Archive of a Subdirectory bis::
  720. File: tar.info,  Node: Creating an Archive of a Subdirectory bis,  Next: Compare bis,  Prev: How to Archive Directories,  Up: How to Create Archives
  721. Creating an Archive from the Superior Directory
  722. -----------------------------------------------
  723.      *(This message will disappear, once this node revised.)*
  724.    You can archive a directory by specifying its directory name as a
  725. file name argument to `tar'.  The files in the directory will be
  726. archived relative to the working directory, and the directory will be
  727. re-created along with its contents when the archive is extracted.
  728.    To archive a directory, first move to its superior directory.  If you
  729. have been following the tutorial, you should type:
  730.      % cd ..
  731.      %
  732.    Once in the superior directory, you can specify the subdirectory as a
  733. file name argument.  To store the directory `practice' in the archive
  734. file `music', type:
  735.      % tar --create --verbose --file=music practice
  736. `tar' should output:
  737.      practice/
  738.      practice/blues
  739.      practice/folk
  740.      practice/jazz
  741.      practice/records
  742.    Note that the archive thus created is not in the subdirectory
  743. `practice', but rather in the working directory--the directory from
  744. which `tar' was invoked.  Before trying to archive a directory from its
  745. superior directory, you should make sure you have write access to the
  746. superior directory itself, not only the directory you are trying
  747. archive with `tar'.  Trying to store your home directory in an archive
  748. by invoking `tar' from the root directory will probably not work.
  749. FIXME: xref absolute-names
  750.    (Note also that `records', the original archive file, has itself
  751. been archived.  `tar' will accept any file as a file to be archived,
  752. regardless of its content.  When `music' is extracted, the archive file
  753. `records' will be re-written into the file system).
  754.    You can store a directory in an archive by using the directory name
  755. as a file name argument to `tar'.  When you specify a directory file,
  756. `tar' archives the directory file and all the files it contains.  The
  757. names of the directory and the files it contains are stored in the
  758. archive relative to the current working directory-when the directory is
  759. extracted they will be written into the file system relative to the
  760. working directory at that time.
  761. FIXME: add an xref to --absolute-names
  762.    To archive a directory, first move to its superior directory.  If you
  763. have been following the tutorial, you should type:
  764.      % cd ..
  765.      %
  766.    Once in the superior directory, specify the subdirectory using a
  767. file name argument.  To store the directory file `~/practice' in the
  768. archive file `music', type:
  769.      % tar --create --verbose --file=music practice
  770.    `tar' should respond:
  771.      practice/
  772.      practice/blues
  773.      practice/folk
  774.      practice/jazz
  775.      practice/records
  776.    Note that `~/practice/records', another archive file, has itself
  777. been archived.  `tar' will accept any file as a file to be archived,
  778. even an archive file.
  779. FIXME: symbolic links and changing directories are now in main body,
  780. FIXME: not in tutorial.
  781. File: tar.info,  Node: Compare bis,  Next: Using Compare from the Superior Directory bis,  Prev: Creating an Archive of a Subdirectory bis,  Up: How to Create Archives
  782. Comparing Files in an Archive with Files in the File System
  783. -----------------------------------------------------------
  784.      *(This message will disappear, once this node revised.)*
  785.    While the `--list' (`-t') operation with the `--verbose' (`-v')
  786. option specified is useful in keeping files in the archive current with
  787. files in the file system (by allowing the user to compare size and
  788. modification dates), it is simpler to have `tar' itself compare file
  789. attributes and report back on file differences.  To do so, use the
  790. `--compare' (`-d') or `--diff' operation.
  791.    The `--compare' (`-d') operation, as its name implies, causes `tar'
  792. to compare files and directories in the archive with their counterparts
  793. (files of the same name) in the file system, and report back
  794. differences in file size, mode, owner and modification date.  When
  795. performing the `--compare' (`-d') operation, `tar' acts only on files
  796. actually in the archive--it will ignore files in the active file system
  797. that do not exist in the archive.  If `tar' with `--compare' (`-d')
  798. specified is given, as a file name argument, the name of a file that
  799. does not exist in the archive, it will return an error message.
  800.    To compare the files in the practice directory with their
  801. counterparts in the archive file `records', in the same directory, you
  802. would, while in the `practice' directory:
  803.    * Invoke `tar' and specify the operation to compare files in the
  804.      archive with their counterparts in the file system--`--compare'
  805.      (`-d') or `--diff'.
  806.    * Specify the name of the archive where the files to be compared are
  807.      stored--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  808.    * Specify the names of the files or directories to be compared, as
  809.      file name arguments (in this case, you are comparing all the files
  810.      in the archive, so nothing need be specified).
  811.      % tar --compare --file=records
  812.      %
  813. While it looks like nothing has happened, `tar' has, in fact, done the
  814. comparison--and found nothing to report.  The same example with the
  815. `--verbose' (`-v') option specified would list the files in the archive
  816. as they are being compared with their counterparts of the same name:
  817.      % tar --compare --verbose --file=records
  818.      blues
  819.      folk
  820.      jazz
  821.      %
  822.    If `tar' had had anything to report, it would have done so as it was
  823. comparing each file.  If you remove the file `jazz' from the file
  824. system (`rm jazz'), and modify the file `blues' (for instance, by
  825. adding text to it with a text editor), the above example would look
  826. like:
  827.      % tar --compare --verbose --file=records
  828.      blues
  829.      blues: mod time differs
  830.      blues: size differs
  831.      folk
  832.      jazz
  833.      jazz: does not exist
  834.      %
  835.    You should note again that while `--compare' (`-d') does cause `tar'
  836. to report back on files in the archive that do not exist in the file
  837. system, `tar' will ignore files in the active file system that do not
  838. exist in the archive.  To demonstrate this, create a file in the
  839. `practice' directory called `rock' (using any text editor).  If you
  840. generate a directory listing the new file will appear.
  841.      % ls
  842.      blues     folk      records  rock
  843. If you run the `--compare' (`-d') example again you will obtain the
  844. following:
  845.      % tar --compare --verbose --file=records
  846.      blues
  847.      blues: mod time differs
  848.      blues: size differs
  849.      folk
  850.      jazz
  851.      jazz: does not exist
  852.      %
  853.    `tar' ignores the file `rock' because `tar' is comparing files in
  854. the archive to files in the file system, not vice versa.  If `rock' had
  855. been passed to `tar' explicitly (as a file name argument), `tar' would
  856. have returned an error message, as follows:
  857.      % tar --compare --verbose --file=records rock
  858.      tar: rock not found in archive
  859.      %
  860.    To compare the attributes of archive members with the attributes of
  861. their counterparts in the file system, use the `--compare' (`-d') or
  862. `--diff'operation.  While you could use `--list --verbose' (`-tv') to
  863. manually compare some file attributes, it is simpler to have `tar'
  864. itself compare file attributes and report back on file differences.
  865. FIXME: "manually"?  suggestions?
  866.    The `--compare' (`-d') operation, as its name implies, compares
  867. archive members with files of the same name in the file system, and
  868. reports back differences in file size, mode, owner and modification
  869. date. `tar +compare' acts only on archive members-it ignores files in
  870. the file system that are not stored in the archive.  If you give with
  871. `--compare' (`-d') a NAME argument that does not correspond to the name
  872. of an archive member, `tar' responds with an error message.
  873.    To compare archive members in the archive file `records' with files
  874. in the `~/practice' directory, first change into the `practice'
  875. directory.  Then:
  876.    * Invoke `tar' and specify the `--compare' (`-d')
  877.      operation--`--compare' (`-d') or `--diff'.
  878.    * Specify the archive where the files to be compared are
  879.      stored--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  880.    * Specify the archive members to be compared.  (In this example you
  881.      are comparing all the archive members in the archive.  Since this
  882.      is the default, you don't need to use any file name arguments).
  883.      % tar --compare --file=records
  884.      %
  885.    While it looks like nothing has happened, `tar' has, in fact, done
  886. the comparison--and found nothing to report.
  887.    Use the `--verbose' (`-v') option to list the names of archive
  888. members as they are being compared with their counterparts of the same
  889. name in the file system:
  890.      % tar --compare --verbose --file=records
  891.      blues
  892.      folk
  893.      jazz
  894.      %
  895.    If `tar' had had anything to report, it would have done so as it was
  896. comparing each file.
  897.    If you remove the file `jazz' from the file system (`rm jazz'), and
  898. modify the file `blues' (for instance, by adding text to it with an
  899. editor such as Emacs), the above example would look like:
  900.      % tar --compare --verbose --file=records
  901.      blues
  902.      blues: mod time differs
  903.      blues: size differs
  904.      folk
  905.      jazz
  906.      jazz: does not exist
  907.      %
  908.    Note again that while `--compare' (`-d') reports the names of archive
  909. members that do not have counterparts in the file system, `--compare'
  910. (`-d') ignores files in the file system that do not have counterparts
  911. in the archive.  To demonstrate this, create a file in the `practice'
  912. directory called `rock' (using any text editor).  The new file appears
  913. when you list the directory's contents:
  914. FIXME: Given an example
  915. File: tar.info,  Node: Using Compare from the Superior Directory bis,  Prev: Compare bis,  Up: How to Create Archives
  916. Using Compare from the Superior Directory
  917. -----------------------------------------
  918.      *(This message will disappear, once this node revised.)*
  919.    In addition to using `--compare' (`-d') to compare individual files
  920. in an archive with their counterparts in the file system, you can use
  921. `--compare' (`-d') to compare archived directories with their
  922. counterparts in the active file system.  You could re-create the
  923. examples above using your home directory as the working directory, and
  924. using the archive file `music' (in which is stored the `practice'
  925. directory) instead of the archive file `records'.
  926.    First, change into the home directory (`cd ..').  Then, try the
  927. above example using `music' as the specified archive file, and the
  928. `practice' subdirectory as a file name argument.
  929.      % tar --compare --verbose --file=music practice
  930.      practice
  931.      practice/blues
  932.      practice/blues: mod time differs
  933.      practice/blues: size differs
  934.      practice/folk
  935.      practice/jazz
  936.      practice/jazz: does not exist
  937.      practice/records
  938.    In addition to using `--compare' (`-d') to compare text files, you
  939. can use `--compare' (`-d') to compare directories.  To illustrate this,
  940. re-create the examples above using your home directory as the working
  941. directory, and using the archive file `~/music' instead of the archive
  942. file `~/practice/records'.
  943.    First, change into your home directory (`cd ~').  Then, try the
  944. above example using `music' as the specified archive file, and
  945. `practice' as a file name argument.
  946.      % tar --compare --verbose --file=music practice
  947.    If you have been following along with the tutorial, `tar' will
  948. respond:
  949.      practice
  950.      practice/blues
  951.      practice/blues: mod time differs
  952.      practice/blues: size differs
  953.      practice/folk
  954.      practice/jazz
  955.      practice/jazz: does not exist
  956.      practice/records
  957. File: tar.info,  Node: How to List Archives,  Next: How to Extract Members from an Archive,  Prev: How to Create Archives,  Up: Tutorial
  958. How to List Archives
  959. ====================
  960.      *(This message will disappear, once this node revised.)*
  961.    Use `--list' (`-t') to print the names of members stored in an
  962. archive.  Use a `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME') option just
  963. as with `--create' (`-c') to specify the name of the archive.  For
  964. example, the archive `afiles.tar' created in the last section could be
  965. examined with the command `tar --list --file=afiles.tar'.  The output
  966. of `tar' would then be:
  967.      apple
  968.      angst
  969.      asparagus
  970.    The archive `bfiles.tar' would list as follows:
  971.      ./baloons
  972.      baboon
  973.      ./bodacious
  974.    (Of course, `tar --list --file=empty-archive.tar' would produce no
  975. output.)
  976.    If you use the `--verbose' (`-v') option with `--list' (`-t'), then
  977. `tar' will print out a listing reminiscent of `ls -l', showing owner,
  978. file size, and so forth.
  979.    You can also specify member names when using `--list' (`-t').  In
  980. this case, `tar' will only list the names of members you identify.  For
  981. example, `tar --list --file=afiles.tar apple' would only print `apple'.
  982. It is essential when specifying member names to `tar' that you give
  983. the exact member names.  For example, `tar --list --file=bfiles
  984. baloons' would produce no output, because there is no member named
  985. `baloons', only one named `./baloons'.  While the file names `baloons'
  986. and `./baloons' name the same file, member names are compared using a
  987. simplistic name comparison, in which an exact match is necessary.
  988. * Menu:
  989. * Listing files in an archive bis::
  990. * Getting Additional File Information bis::
  991. * List A Specific File in an Archive bis::
  992. * Listing the Contents of a Stored Directory ter::
  993.