home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tar-1.11.8-bin.lha / info / tar.info-2 (.txt) < prev    next >
GNU Info File  |  1996-10-12  |  48KB  |  906 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: Listing files in an archive bis,  Next: Getting Additional File Information bis,  Prev: How to List Archives,  Up: How to List Archives
  21. Listing the Contents of an Archive
  22. ----------------------------------
  23.      *(This message will disappear, once this node revised.)*
  24.    You can list the contents of the archive you just created with
  25. another option of `tar': `--list' (`-t').  To list the contents of an
  26. archive, type:
  27.      % tar --list --file=records
  28.    `tar' will respond:
  29.      blues folk jazz
  30. FIXME: xref Listing Archive Contents
  31.    , for a more detailed tutorial of the `--list' (`-t') operation.
  32. FIXME: xref Listing Contents
  33.    for more information about the `--list' (`-t') operation.
  34. FIXME:
  35.    You can use `--list' (`-t') to output a list of the files in an
  36. archive.  If you use file name arguments with this operation, `tar'
  37. will look in the archive for the files specified and display their
  38. names only if they are, in fact, stored.  You can use `--list' (`-t')
  39. with the `--verbose' (`-v') option to find out the attributes (owner,
  40. size, etc.) of stored files.
  41.    You can list the contents of an archive with another operation of
  42. `tar': `--list' (`-t').  To list the contents of the archive you just
  43. created, type:
  44.      % tar --list --file=records
  45.    `tar' will respond:
  46.      blues folk jazz
  47. FIXME: xref Listing Archive Contents
  48.    , for a more detailed tutorial of the `--list' (`-t') operation.
  49. FIXME: xref Listing Contents
  50.    , for more information about the `--list' (`-t') operation.
  51.    In a previous example, you created the archive `music' in the home
  52. directory.  To list the contents of `music':
  53.    * List the contents of an archive by using `--list' (`-t') with
  54.      `tar'.
  55.    * Specify the name of the archive to be
  56.      listed--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  57.    Thus:
  58.      % tar --list --file=music
  59.      practice/
  60.      practice/blues
  61.      practice/folk
  62.      practice/jazz
  63.      practice/records
  64.    Use `--list' (`-t') to print the names of files stored in an
  65. archive.  If you use file name arguments with this operation, `tar'
  66. prints the names of the specified files if they are stored in the
  67. archive.  If you use a directory name as a file name argument, `tar'
  68. also prints the names of all underlying files, including
  69. sub-directories.  If you use no file name arguments, `tar' prints the
  70. names of all the archive members.
  71.    You can use `--list' (`-t') with the `--verbose' (`-v') option to
  72. print archive members' attributes (owner, size, etc.).
  73.    To list the names of files stored in an archive, use the `--list'
  74. (`-t') operation of `tar'.
  75.    In a previous example, you created the archive `~/music'.  To list
  76. the contents of `music', while in your home directory:
  77.    * List the contents of an archive by using {No Value For "-list"}
  78.      with `tar'.
  79.    * Specify the archive to be listed--`--file=ARCHIVE-NAME' (`-f
  80.      ARCHIVE-NAME').
  81.    Thus:
  82.      % tar --list --file=music
  83.      practice/
  84.      practice/blues
  85.      practice/folk
  86.      practice/jazz
  87.      practice/records
  88. File: tar.info,  Node: Getting Additional File Information bis,  Next: List A Specific File in an Archive bis,  Prev: Listing files in an archive bis,  Up: How to List Archives
  89. Getting Additional File Information
  90. -----------------------------------
  91.      *(This message will disappear, once this node revised.)*
  92.    When you specify the `--verbose' (`-v') option in conjunction with
  93. `--list' (`-t'), `tar' will print additional information about the
  94. files being listed (file protection, owner and group ID, size, and date
  95. and time of creation).  The example above, in verbose mode, would be:
  96.      % tar --list --verbose --file=music
  97.      drwxrwxrwx myself/user 0 May 31 21:49 1990 practice/
  98.      -rw-rw-rw- myself/user 42 May 21 13:29 1990 practice/blues
  99.      -rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
  100.      -rw-rw-rw- myself/user 40 May 21 13:30 1990 practice/jazz
  101.      -rw-rw-rw- myself/user 10240 May 31 21:49 1990 practice/records
  102.      %
  103.    Note that using `--verbose' (`-v') with `--list' (`-t') does not
  104. cause `tar' to print the names of files as they are being acted on,
  105. though the `--verbose' (`-v') option will have this effect with all
  106. other operations.
  107.    To get more information when you list the names of files stored in an
  108. archive, specify the `--verbose' (`-v') option in conjunction with
  109. `--list' (`-t').
  110.    `tar' will print archive member's file protection, owner and group
  111. ID, size, and date and time of creation.
  112.    For example:
  113.      % tar --list --verbose --file=music
  114.      drwxrwxrwx myself/user 0 May 31 21:49 1990 practice/
  115.      -rw-rw-rw- myself/user 42 May 21 13:29 1990 practice/blues
  116.      -rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
  117.      -rw-rw-rw- myself/user 40 May 21 13:30 1990 practice/jazz
  118.      -rw-rw-rw- myself/user 10240 May 31 21:49 1990 practice/records
  119.      %
  120.    Note that when you use `--verbose' (`-v') with `--list' (`-t'),
  121. `tar' doesn't print the names of files as they are being acted on,
  122. though the `--verbose' (`-v') option will have this effect when used
  123. with all other operations.
  124. File: tar.info,  Node: List A Specific File in an Archive bis,  Next: Listing the Contents of a Stored Directory ter,  Prev: Getting Additional File Information bis,  Up: How to List Archives
  125. List A Specific File in an Archive
  126. ----------------------------------
  127.      *(This message will disappear, once this node revised.)*
  128. FIXME:
  129.    To to see if a particular file is in an archive, specify the name of
  130. the file in question as a file name argument while specifying the
  131. `--list' (`-t') operation.  For example, if you wanted to see if the
  132. file `folk' were in the archive file `music', you would:
  133.    * Invoke `tar', and specify the operation to list the contents of an
  134.      archive--`--list' (`-t').
  135.    * Specify the name of the archive file to be acted
  136.      on--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  137.    * Specify the name of the file `tar' is to look for, as a file name
  138.      argument.  Because `tar' preserves paths, file names must be
  139.      specified as they appear in the archive (ie.. as they are relative
  140.      to the directory from which the archive was created).
  141.      FIXME: xref -P
  142.    Type:
  143.      % tar --list --file=music practice/folk
  144. `tar' responds:
  145.      practice/folk
  146. If the file were not in the archive (for example, the file
  147. `practice/rock'), the example above would look like:
  148.      % tar --list --file=music practice/rock
  149.      tar: practice/rock not found in archive
  150.    The `--verbose' (`-v') option does not have any effect on execution
  151. of the `--list' (`-t') operation when you have specified file name
  152. arguments.
  153. FIXME: this is a bug (?)
  154.    To to see if a particular file is in an archive, use the name of the
  155. file in question as a file name argument while specifying the `--list'
  156. (`-t') operation.  For example, to see whether the file `folk' is in the
  157. archive file `music', do the following:
  158.    * Invoke `tar', and specify the `--list' (`-t') operation.
  159.    * Specify the archive file to be acted on--`--file=ARCHIVE-NAME'
  160.      (`-f ARCHIVE-NAME').
  161.    * Specify the files to look for, by typing their names as file name
  162.      arguments.  You have to type the file name as it appears in the
  163.      archive (normally, as it is relative to the relative to the
  164.      directory from which the archive was created).
  165.      FIXME: xref absolute-names
  166.    Type:
  167.      % tar --list --file=music practice/folk
  168.    `tar' responds:
  169.      practice/folk
  170.    If the file were not stored in the archive (for example, the file
  171. `practice/rock'), the example above would look like:
  172.      % tar --list --file=music practice/rock
  173.      tar: practice/rock not found in archive
  174.    If you had used `--verbose' (`-v') mode, the example above would
  175. look like:
  176.      % tar --list --file=music practice/folk
  177.      -rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
  178. File: tar.info,  Node: Listing the Contents of a Stored Directory ter,  Prev: List A Specific File in an Archive bis,  Up: How to List Archives
  179. Listing the Contents of a Stored Directory
  180. ------------------------------------------
  181.      *(This message will disappear, once this node revised.)*
  182.    To get information about the contents of an archived directory, use
  183. the directory name as a file name argument in conjunction with `--list'
  184. (`-t').  To find out file attributes, include the `--verbose' (`-v')
  185. option.
  186.    For example, to find out about files in the directory `practice', in
  187. the archive file `music', type:
  188.      % tar --list --file=music practice
  189.    `tar' responds:
  190.      drwxrwxrwx myself/user 0 May 31 21:49 1990 practice/
  191.      -rw-rw-rw- myself/user 42 May 21 13:29 1990 practice/blues
  192.      -rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
  193.      -rw-rw-rw- myself/user 40 May 21 13:30 1990 practice/jazz
  194.      -rw-rw-rw- myself/user 10240 May 31 21:49 1990 practice/records
  195.    When you use a directory name as a file name argument, `tar' acts on
  196. all the files (including sub-directories) in that directory.
  197. File: tar.info,  Node: How to Extract Members from an Archive,  Next: How to Add Files to Existing Archives,  Prev: How to List Archives,  Up: Tutorial
  198. How to Extract Members from an Archive
  199. ======================================
  200.      *(This message will disappear, once this node revised.)*
  201.    In order to extract members from an archive, use the `--extract'
  202. (`-x') option.  Specify the name of the archive with
  203. `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').  To extract specific archive
  204. members, give their member names as arguments.  It essential to give
  205. their exact member name, as printed by `--list' (`-t').  This will
  206. create a copy of the archive member, with a file name the same as its
  207. name in the archive.
  208.    Keeping the example of the two archives created at the beginning of
  209. this tutorial, `tar --extract --file=afiles.tar apple' would create a
  210. file `apple' in the current directory with the contents of the archive
  211. member `apple'.  It would remove any file named `apple' already present
  212. in the directory, but it would not change the archive in any way.
  213.    Remember that specifying the exact member name is important.  `tar
  214. --extract --file=bfiles.tar baloons' will fail, because there is no
  215. member named `baloons'.  To extract the member named `./baloons' you
  216. would need to specify `tar --extract --file=bfiles.tar ./baloons'.  To
  217. find the exact member names of the members of an archive, use `--list'
  218. (`-t').
  219. FIXME: xref Listing Archives.
  220.    If you do not list any archive member names, then `--extract' (`-x')
  221. will extract all the members of the archive.
  222.    If you give the `--verbose' (`-v') option, then `--extract' (`-x')
  223. will print the names of the archive members as it extracts them.
  224. * Menu:
  225. * Extracting Files bis::
  226. * Extracting Files from an Archive ter::
  227. * Extracting Specific Files ter::
  228. * Extracting Directories ter::
  229. File: tar.info,  Node: Extracting Files bis,  Next: Extracting Files from an Archive ter,  Prev: How to Extract Members from an Archive,  Up: How to Extract Members from an Archive
  230. Extract Files from an Archive into Your Current Directory
  231. ---------------------------------------------------------
  232.      *(This message will disappear, once this node revised.)*
  233.    Obviously, the ultimate goal of `tar' users is to eventually get
  234. their files back.  To do this, use the `--extract' (`-x') or `--get'
  235. operation.  `--extract' (`-x') can be used to retrieve individual files
  236. from an archive, or can be used to write all the files in the archive
  237. back into the file system.
  238.    In the previous example you concatenated two archives, `music', and
  239. `practice/records'.  To now retrieve the complete contents of `music'
  240. (the target file in the concatenation process), you would, from the
  241. home directory:
  242.    * Invoke `tar' and specify the operation to extract files from an
  243.      archive (`--extract' (`-x') or `--get'.
  244.    * Specify the name of the archive the files will be extracted
  245.      from--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  246.    * Specify the names of the files you wish to extract, as file name
  247.      arguments (in this case you want to extract the entire archive, so
  248.      you don't need to specify anything).
  249.      % tar --extract --file=music
  250.      tar: Could not make directory practice : File exists
  251. Because the files stored originally in `music' were stored as files in
  252. a subdirectory (not as files in the working directory), they are stored
  253. in the archive with a leading directory name--`tar', in restoring them,
  254. has tried to recreate that directory and failed: the directory already
  255. exists.  The extraction has not been aborted, however.  If you now
  256. change into the `practice' directory and generate a directory listing,
  257. you will find that `jazz', which we removed in an earlier example, has
  258. been resurrected.
  259.      % cd practice
  260.      % ls
  261.      blues       classical  folk     jazz        records    rock
  262.    If you look more closely at the files in the directory, however, you
  263. will find that `blues' and `folk' are, in fact, the original versions
  264. of the file, which were stored in `music' at the beginning of the
  265. tutorial.  `tar', in extracting the original files from `music', has
  266. overwritten the existing files in the file system.
  267.    While the newer versions of the files were stored in `records'
  268. above, they can no longer be extracted from it.  `records' too was
  269. archived by `tar' when the `practice' directory was stored in the
  270. archive file `music', and was restored to its older incarnation when
  271. the files in `practice' were overwritten.  However, the newer version
  272. of `records' was concatenated with `music'.  The contents of the newer
  273. version of `records', therefore, should have been extracted when all
  274. the contents of `music' were extracted.  They were.  `tar' has restored
  275. them into the working directory using the names with which they were
  276. originally stored.  Because they were originally stored as part of
  277. `records', in the `practice' directory, they had no preceeding
  278. directory stored as part of their file names.  To find the latest
  279. versions of `blues', `folk', `jazz', `rock' and `classical', look in
  280. your home directory.
  281.    You may wish to restore the files in your `practice' directory to
  282. their last state before we extracted the files from `music'.  Rather
  283. than moving the files from your home directory to the `practice'
  284. subdirectory, you can run the same extraction procedure as above using
  285. the `practice' subdirectory as your working directory:
  286.      % cd practice
  287.      % tar --extract --verbose --file=~/music
  288.      practice/
  289.      practice/blues
  290.      practice/folk
  291.      practice/jazz
  292.      practice/records
  293.      blues
  294.      folk
  295.      jazz
  296.      blues
  297.      rock
  298.      blues
  299.      classical
  300.      %
  301. If you now examine the files in the practice directory, you will find
  302. that the files have been restored to their previous, newer, states.
  303. The old versions of the files, which were stored in `music' with a
  304. preceeding directory name, have been written into a newly created
  305. subdirectory under the working directory (which is your `practice'
  306. subdirectory).  The new subdirectory is also called `practice'.
  307. File: tar.info,  Node: Extracting Files from an Archive ter,  Next: Extracting Specific Files ter,  Prev: Extracting Files bis,  Up: How to Extract Members from an Archive
  308. Extracting Files from an Archive
  309. --------------------------------
  310.      *(This message will disappear, once this node revised.)*
  311.    Creating an archive is only half the job--there would be no point in
  312. storing files in an archive if you couldn't retrieve them.  To extract
  313. files from an archive, use the `--extract' (`-x') operation.
  314.    To extract specific files, use their names as file name arguments.
  315. If you use a directory name as a file name argument, `tar' extracts all
  316. the files (including subdirectories) in that directory.  If you don't
  317. use any file name arguments, `tar' extracts all the files in the
  318. archive.
  319.    Note: `tar' will extract an archive member into the file system
  320. without checking to see if there is already a file with the archive
  321. member's file name.  If there is a file with that name, `tar' will
  322. *overwrite* that file and its contents will be lost.
  323. FIXME: xref keep-old
  324. File: tar.info,  Node: Extracting Specific Files ter,  Next: Extracting Directories ter,  Prev: Extracting Files from an Archive ter,  Up: How to Extract Members from an Archive
  325. Extracting Specific Files
  326. -------------------------
  327.      *(This message will disappear, once this node revised.)*
  328.    To extract specific files, specify them using file name arguments.
  329.    In an example above, you created the archive file
  330. `~/practice/records', which contained the files `blues', `folk' and
  331. `jazz' in the `practice' directory.  If, for some reason, you were to
  332. lose one of those text files (`rm ~/practice/blues'), you could extract
  333. it from the archive file.
  334.    First, change into the `practice' directory.  Then,
  335.    * Invoke `tar' and specify the `--extract' (`-x') or `--get'
  336.      operation.
  337.    * Specify the archive that the files will be extracted
  338.      from--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  339.    * Specify the files to extract, using file name arguments (if you
  340.      don't specify any files, `tar' extracts all the archive members)
  341.      % tar --extract --file=records blues
  342.    If you list the contents of the directory, you will see that `blues'
  343. is back:
  344.      % ls
  345.      folk
  346.      jazz
  347.      records
  348.      blues
  349. File: tar.info,  Node: Extracting Directories ter,  Prev: Extracting Specific Files ter,  Up: How to Extract Members from an Archive
  350. Extracting Directories
  351. ----------------------
  352.      *(This message will disappear, once this node revised.)*
  353.    To extract a directory and all the files it contains, use the
  354. directory's name as a file name argument in conjunction with `tar
  355. +extract'.  Remember-`tar' stores and extracts file names relative to
  356. the working directory.
  357.    In a previous example you stored the directory `~/practice' in the
  358. archive file `~/music'.  If you delete the contents of `practice', you
  359. can restore them using `tar'.
  360.    First, change into the `practice' subdirectory (`cd ~/practice').
  361. Then, remove all the files in `~/practice' (`rm *').  If you list the
  362. contents of the directory, you should now see that it is empty:
  363.      %ls
  364.      %
  365.    Let's try to restore the contents of `practice' by extracting them
  366. from the archive file `~/music':
  367.      tar --extract --file=~/music practice
  368.    Now, list the contents of `practice' again:
  369.      %ls
  370.      practice
  371.    What happened to the files?  When you created `~/music', your
  372. working directory was your home directory.  When you extracted
  373. `~/music', your working directory was `~/practice'. `tar' stored the
  374. files in `practice' relative to your home directory, and then extracted
  375. them relative to `~/practice'.  The files are now in a new
  376. subdirectory, called `~/practice/practice'.
  377.    To restore your files to their old positions, delete the new
  378. directory and its contents, and then redo the example above with your
  379. home directory as the working directory:
  380.      % rm ~/practice/practice/*
  381.      % rmdir practice
  382.      % cd ..
  383.      % tar --extract --file=music practice
  384.    (`tar' will report that it is unable to create the directory
  385. `~/practice' because it already exists.  This will not effect the
  386. extraction of the other archive members.)
  387. File: tar.info,  Node: How to Add Files to Existing Archives,  Next: How to Delete Members from Archives,  Prev: How to Extract Members from an Archive,  Up: Tutorial
  388. How to Add Files to Existing Archives
  389. =====================================
  390.      *(This message will disappear, once this node revised.)*
  391.    If you want to add files to an existing archive, then don't use
  392. `--create' (`-c').  That will erase the archive and create a new one in
  393. its place.  Instead, use `--append' (`-r').  The command `tar --append
  394. --file=afiles.tar arbalest' would add the file `arbalest' to the
  395. existing archive `afiles.tar'.  The archive must already exist in order
  396. to use `--append' (`-r').
  397.    As with `--create' (`-c'), the member names of the newly added files
  398. will be the exact same as their names given on the command line.  The
  399. `--verbose' (`-v') option will print out the names of the files as they
  400. are written into the archive.
  401.    If you add a file to an archive using `--append' (`-r') with the
  402. same name as an archive member already present in the archive, then the
  403. old member is not deleted.  What does happen, however, is somewhat
  404. complex.
  405. FIXME: xref Multiple Members with the Same Name.
  406.    If you want to replace an archive member, use `--delete' first, and
  407. then use `--append' (`-r').
  408. FIXME: we want people to use the script for backups, so I an not going
  409. FIXME: to use backups as an explanation in the tutorial.  (people can still
  410. FIXME: do it if they really want to)
  411.    While you can use `tar' to create a new archive every time you want
  412. to store a file, it is more sometimes efficient to add files to an
  413. existing archive.
  414.    To add new files to an existing archive, use the `--append' (`-r')
  415. operation.  To add newer versions of archive members to an archive, use
  416. the `--update' (`-u') operation.
  417.    While you can use `tar' to create an archive of an entire directory
  418. or directory tree, it is more efficient when performing backups to only
  419. archive those files which have been newly created or changed since the
  420. last backup.
  421.    To add new files to an existing archive, or to add newer versions of
  422. old files, you can use the `--append' (`-r') operation, or the
  423. `--update' (`-u') operation.
  424. * Menu:
  425. * Append bis::
  426. * Update bis::
  427. * Concatenate bis::
  428. File: tar.info,  Node: Append bis,  Next: Update bis,  Prev: How to Add Files to Existing Archives,  Up: How to Add Files to Existing Archives
  429. Appending Files to an Archive
  430. -----------------------------
  431.      *(This message will disappear, once this node revised.)*
  432.    The simplest method of adding a file to an already existing archive
  433. is the `--append' (`-r') operation, which writes the files specified
  434. into the archive without regard to whether or not they are already
  435. among the archived files.  When you use `--append' (`-r') you must
  436. specify file name arguments, there is no default.  If you specify a
  437. file that already exists in the archive another copy of the file will
  438. be added to the end of the archive anyway.
  439.    In the previous examples you created a file called `rock' in the
  440. practice directory which did not exist in either the archive file
  441. `records', in the practice directory, or the archive file `music', in
  442. the home directory.  To add `rock' to `records', you would, while in
  443. the practice directory:
  444.    * Invoke `tar' and specify the operation to add a file--`--append'
  445.      (`-r').
  446.    * Specify the name of the archive to which the file will be
  447.      added--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  448.    * Specify the name(s) of the file(s) to be added to the archive as
  449.      the file name argument(s)
  450.      % tar --append --file=records rock
  451. If you now use the `--list' (`-t') operation, you will see that `rock'
  452. has been added to the archive:
  453.      % tar --list --file=records
  454.      blues
  455.      folk
  456.      jazz
  457.      rock
  458.    While all newly created files have now been added to `records', it
  459. is still not current with respect to the contents of the practice
  460. directory.  If you recall from the examples using `--compare' (`-d')
  461. above, `blues' was changed after the archive `records' was created.  It
  462. is simple, however, to use `--append' (`-r') to correct the problem:
  463.      % tar --append --verbose --file=records blues
  464.      blues
  465. Because you specified the `--verbose' (`-v') option, `tar' has printed
  466. the name of the file being appended as it was acted on.  If you now use
  467. `tar' with the `--list' (`-t') option specified to get the contents of
  468. the archive, you will optain the following:
  469.      % tar --list -f records
  470.      blues
  471.      folk
  472.      jazz
  473.      rock
  474.      blues
  475. The newest version of `blues' is now at the end of the archive.
  476. Because files are extracted from archives in the order in which they
  477. appear in the archive, and because extracted files are given the same
  478. names in the file system as they are stored under in the archive, when
  479. the files in `records' are extracted the newer version of `blues'
  480. (which has the same name as the older) will overwrite the version
  481. stored first.
  482. FIXME: xref Keep Old Files
  483. FIXME: --update wont take a directory argument if files that have been
  484. FIXME: archived from that directory are now no longer in it.  (I assume
  485. FIXME: because it looks in the archive first for the directory listing.)
  486. FIXME: this is a bug
  487.    The simplest method of adding a file to an existing archive is the
  488. `--append' (`-r') operation, which writes files into the archive
  489. without regard to whether or not they are already archive members.
  490. When you use `--append' (`-r') you must use file name arguments; there
  491. is no default.  If you specify a file that is already stored in the
  492. archive, `tar' adds another copy of the file to the archive.
  493.    If you have been following the previous examples, you should have a
  494. text file called `~/practice/rock' which has not been stored in either
  495. the archive file `~/practice/records', or the archive file `~/music'.
  496. To add `rock' to `records', first make `practice' the working directory
  497. (`cd practice').  Then:
  498.    * Invoke `tar' and specify the `--append' (`-r') operation.
  499.    * Specify the archive to which the file will be
  500.      added--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  501.    * Specify the files to be added to the archive, using file name
  502.      arguments
  503.    For example:
  504.      % tar --append --file=records rock
  505.    If you list the archive members in `records', you will see that
  506. `rock' has been added to the archive:
  507.      % tar --list --file=records
  508.      blues
  509.      folk
  510.      jazz
  511.      rock
  512. FIXME: this should be some kind of node.
  513.    You can use `--append' (`-r') to keep archive members current with
  514. active files.  Because `--append' (`-r') stores a file whether or not
  515. there is already an archive member with the same file name, you can use
  516. `--append' (`-r') to add newer versions of archive members to an
  517. archive.  When you extract the file, only the version stored last will
  518. wind up in the file system.  Because `--extract' (`-x') extracts files
  519. from an archive in sequence, and overwrites files with the same name in
  520. the file system, if a file name appears more than once in an archive
  521. the last version of the file will overwrite the previous versions which
  522. have just been extracted.
  523.    If you recall from the examples using `--compare' (`-d') above,
  524. `blues' was changed after the archive `records' was created. It is
  525. simple, however, to use `--append' (`-r') to add the new version of
  526. `blues' to `records':
  527.      % tar --append --verbose --file=records blues
  528.      blues
  529.    If you now list the contents of the archive, you will obtain the
  530. following:
  531.      % tar --list -f records
  532.      blues
  533.      folk
  534.      jazz
  535.      rock
  536.      blues
  537.    The newest version of `blues' is at the end of the archive.  When the
  538. files in `records' are extracted, the newer version of `blues' (which
  539. has the same name as the older) will overwrite the version stored
  540. first.  When `--extract' (`-x') is finished, only the newer version of
  541. `blues' is in the file system.
  542. FIXME: xref keep-old-files
  543. File: tar.info,  Node: Update bis,  Next: Concatenate bis,  Prev: Append bis,  Up: How to Add Files to Existing Archives
  544. Updating Files in an Archive
  545. ----------------------------
  546.      *(This message will disappear, once this node revised.)*
  547.    While the `--append' (`-r') option is useful for updating files in an
  548. archive, to keep an archive current with `--append' (`-r') you must
  549. first use the `--compare' (`-d') or `--list' (`-t') options to determine
  550. what files have been changed (or be willing to waste space by adding
  551. identical copies of archived files to the ends of archives).  It is
  552. simpler to use the `--update' (`-u') operation, and let `tar' do the
  553. work for you.
  554.    The `--update' (`-u') option causes `tar' to add files to the end of
  555. an archive, just like the `--append' (`-r') option.  When you invoke
  556. `tar' with the `--update' (`-u') option specified you must specify file
  557. name arguments.  Unlike `--append' (`-r'), the `--update' (`-u') option
  558. causes `tar' to check the archive to be updated to see if the specified
  559. file is already stored.  If the file (or one with the same name) is
  560. already in the archive, `tar' checks the modification date of the file
  561. in the archive and compares it to the file of the same name in the file
  562. system.  The file is only appended to the archive if it is new or if
  563. its modification date has changed to a later one.
  564. FIXME: xref After-Date
  565.    To see the `--update' (`-u') option at work, create a new file,
  566. `classical', in your practice directory, and add a line to the file
  567. `blues', using any text editor.  Then invoke `tar' with the `--update'
  568. (`-u') operation and the `--verbose' (`-v') option specified, using the
  569. names of all the files in the practice directory as file name arguments:
  570.      % tar --update --verbose --file=records blues folk rock classical
  571.      blues
  572.      classical
  573.      %
  574. Because we have specified verbose mode, `tar' prints out the names of
  575. the files it is working on, which in this case are the names of the
  576. files that needed to be updated.  If you now invoke `tar' with the
  577. `--list' (`-t') operation specified, to generate a listing of the files
  578. in the archive, you will see that `blues' and `classical' have been
  579. added to its end.
  580.    [The reason `tar' does not overwrite the older file when updating it
  581. is because writing to the middle of a section of tape is a difficult
  582. process.  Tapes are not designed to go backward.  Even if they were,
  583. imagine what would happen if the newer version were longer than the
  584. older one.]
  585.    To keep archive members up to date with their counterparts of the
  586. same name in the file system, use the `--update' (`-u') option.  This
  587. adds a specified file to an archive if no file of that name is already
  588. stored in the archive.  If there is already an archive member with the
  589. same name, `tar' checks the modification date of the archive member,
  590. and adds the file only if its modification date is later.  If a file is
  591. stored in the archive but no longer exists under the same name in the
  592. active file system, `tar' reports an error.
  593.    You could use the `--append' (`-r') option to keep an archive
  594. current, but do so you would either have to use the `--compare' (`-d')
  595. and `--list' (`-t') options to determine what files needed to be
  596. re-archived (which could waste a lot of time), or you would have to be
  597. willing to add identical copies of already archived files to the
  598. archive (which could waste a lot of space).
  599.    You must use file name arguments with the `--update' (`-u')
  600. operation-if you don't specify any files, `tar' won't act on any files.
  601.    To see the `--update' (`-u') option at work, create a new file,
  602. `~/practice/classical', and modify the file `~/practice/blues' (you can
  603. use a text editor, such as Emacs, to do both these things).  Then, with
  604. `practice' as your working directory, invoke `tar' with the `--update'
  605. (`-u') option, using the names of all the files in the practice
  606. directory as file name arguments, and specifying the `--verbose' (`-v')
  607. option:
  608.      % tar --update --verbose --file=records blues folk rock classical
  609.      blues
  610.      classical
  611.      %
  612.    Because you specified verbose mode, `tar' printed out the names of
  613. the files it acted on.  If you now list the archive members of the
  614. archive, (`tar --list --file=records'), you will see that the file
  615. `classical' and another version of the file `blues' have been added to
  616. `records'.
  617.    Note: When you update an archive, `tar' does not overwrite old
  618. archive members when it stores newer versions of a file.  This is
  619. because archive members appear in an archive in the order in which they
  620. are stored, and some archive devices do not allow writing in the middle
  621. of an archive.
  622. File: tar.info,  Node: Concatenate bis,  Prev: Update bis,  Up: How to Add Files to Existing Archives
  623. Concatenating Archives
  624. ----------------------
  625.      *(This message will disappear, once this node revised.)*
  626.    Rather than adding individual files onto the end of an archive, it
  627. may be more convenient to add archives themselves onto the end of an
  628. archive.  While it may seem intuitive to use `cat', the utility for
  629. adding files together, for this purpose, archives created by `tar'
  630. incorporate an end of file marker which must be removed if the
  631. concatenated archives are to be read properly as one archive
  632. FIXME: xref Ignore zeros.
  633.    To add archives to the end of another archive, therefore, you should
  634. use the `--concatenate' (`-A') operation.
  635.    In earlier examples you created an archive file, `music', in your
  636. home directory.  You have, however, since changed the contents of the
  637. `practice' directory which was stored in that archive.  `records', the
  638. archive file in the `practice' directory, has recently been updated,
  639. and contains a current version of the files in `practice'.  Rather than
  640. update the contents of `music', let's add `records' to it.
  641.    * Change into the home directory (`cd ..')
  642.    * Invoke `tar', and specify the operation to add archives to the end
  643.      of another archive--`--concatenate' (`-A').
  644.    * Specify the name of the archive file to be added
  645.      to--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  646.    * Specify the file name arguments, which are, unusually, the names of
  647.      archive files.  Remember to include the directory name in the file
  648.      name, if the archive file is not in your working directory.
  649.      % cd ..
  650.      % tar --concatenate --file=music practice/records
  651.    Rather than list the new contents of `music', let's extract all the
  652. files and see what happens.
  653.    To concatenate archive files, use the `--concatenate' (`-A') option.
  654. This operation adds other archives to the end of an archive. While it
  655. may seem intuitive to concatenate archives using `cat', the utility for
  656. adding files together, archive files which have been "catted" together
  657. cannot be read properly by `tar'.  Archive files incorporate an end of
  658. file marker-if archives are concatenated using `cat', this marker will
  659. appear before the end of the new archive.  This will interfere with
  660. operations on that archive.
  661. FIXME: xref ignore-zeros
  662.    In earlier examples, you stored the `~/practice' directory in an
  663. archive file, `~/music'.  If you have been following the examples, you
  664. have since changed the contents of the `~/practice' directory.  There
  665. is a current version of the files in the `practice' directory, however,
  666. stored in the archive file `~/practice/records'.
  667.    To store current versions of the files in `practice' in the archive
  668. file `music', you can use `--concatenate' (`-A') to add the archive file
  669. `~/practice/records' to `music'.  First, make sure you are in your home
  670. directory (`cd ~').  Then:
  671.    * Invoke `tar', and specify the `--concatenate' (`-A') operation.
  672.    * Specify the archive file to be added to--`--file=ARCHIVE-NAME'
  673.      (`-f ARCHIVE-NAME').
  674.    * Specify the archives to be added, using file name arguments.  In
  675.      this case, the file name arguments are, unusually, the names of
  676.      archive files.  (Remember to include the path in the archive name,
  677.      if the archive file is not in your working directory.)
  678.      % cd ~
  679.      % tar --concatenate --file=music practice/records
  680.    If you now list the contents of the `music', you see it now contains
  681. the archive members of `practice/records':
  682.      %tar --list --file=music
  683.      blues
  684.      folk
  685.      jazz
  686.      rock
  687.      blues
  688.      practice/blues
  689.      practice/folk
  690.      practice/jazz
  691.      practice/rock
  692.      practice/blues
  693.      practice/classical
  694. File: tar.info,  Node: How to Delete Members from Archives,  Prev: How to Add Files to Existing Archives,  Up: Tutorial
  695. How to Delete Members from Archives
  696. ===================================
  697.      *(This message will disappear, once this node revised.)*
  698.    You can delete members from an archive using `--delete'.  Specify
  699. the name of the archive with `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  700. List the member names of the members to be deleted.  (If you list no
  701. member names, then nothing will be deleted.)  The `--verbose' (`-v')
  702. option will cause `tar' to print the names of the members as they are
  703. deleted.  As with `--extract' (`-x'), it is important that you give the
  704. exact member names when using `tar --delete'.  Use `--list' (`-t') to
  705. find out the exact member names in an archive.
  706. FIXME: xref Listing Archives.
  707.    The `--delete' option only works with archives stored on disk.  You
  708. cannot delete members from an archive stored on a tape.
  709.    In some instances, it may be advantageous to remove some files from
  710. an archive stored on disk (it is never advantageous to delete files from
  711. an archive stored on tape--the linear nature of tape storage makes this
  712. action likely to scramble the archive).  You can use the `--delete'
  713. operation to remove files from an archive.  The names of files to be
  714. removed must be specified to `tar' as file name arguments.  All
  715. versions of the named file are removed from the archive.  Execution of
  716. the `--delete' operation can be very slow.
  717.    To delete all versions of the file `blues' from the archive
  718. `records' in the `practice' directory, make sure you are in that
  719. directory, and then,
  720.    * List the contents of the archive file `records' (see above for the
  721.      steps involved) to insure that the file(s) you wish to delete are
  722.      stored in the archive.  (This step is optional)
  723.    * Invoke `tar' and specify the operation to delete files from an
  724.      archive (`--delete')
  725.    * Specify the name of the archive file that the file(s) will be
  726.      deleted--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  727.    * Specify the name(s) of the file(s) to be deleted, as file name
  728.      arguments
  729.    * List the contents of the archive file again--note that the files
  730.      have been removed.  (this step is also optional)
  731.      % tar --list --file=records
  732.      blues
  733.      folk
  734.      jazz
  735.      % tar --delete --file=records blues
  736.      % tar --list --file=records
  737.      folk
  738.      jazz
  739.      %
  740.    In some instances, you may want to remove some files from an archive
  741. stored on disk
  742.      *Caution:* you should never delete files from an archive stored on
  743.      tape-because of the linear nature of tape storage, doing this is
  744.      likely to scramble the archive.
  745.    To remove archive members from an archive, use the `--delete'
  746. operation.  You must specify the names of files to be removed as file
  747. name arguments.  All versions of the named file are removed from the
  748. archive.
  749.    Execution of the `--delete' operation can be very slow.
  750.    To delete all versions of the file `blues' from the archive
  751. `records' in the `practice' directory, make sure you are in that
  752. directory, and then:
  753.    * List the contents of the archive file `records' (see above for the
  754.      steps involved) to insure that the file(s) you wish to delete are
  755.      stored in the archive.  (This step is optional)
  756.    * Invoke `tar' and specify the `--delete' operation (`--delete').
  757.    * Specify the name of the archive file that the file(s) will be
  758.      deleted from--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').
  759.    * Specify the files to be deleted, using file name arguments.
  760.    * List the contents of the archive file again--note that the files
  761.      have been removed.  (this step is also optional)
  762.      % tar --list --file=records
  763.      blues
  764.      folk
  765.      jazz
  766.      % tar --delete --file=records blues
  767.      % tar --list --file=records
  768.      folk
  769.      jazz
  770.      %
  771. File: tar.info,  Node: Invoking tar,  Next: Basic tar Operations,  Prev: Tutorial,  Up: Top
  772. Invoking GNU `tar'
  773. ******************
  774.      *(This message will disappear, once this node revised.)*
  775. * Menu:
  776. * Synopsis::
  777. * Option Styles::
  778. * Options::
  779. File: tar.info,  Node: Synopsis,  Next: Option Styles,  Prev: Invoking tar,  Up: Invoking tar
  780. General Synopsis of `tar'
  781. =========================
  782.    The usual way to invoke `tar' is:
  783.      tar OPTION... [NAME]...
  784.    You can actually type in arguments in any order, but in this manual
  785. the options always precede the other arguments, to make examples easier
  786. to understand.  Further, the option stating the main operation mode
  787. (the `tar' "main command") is usually given first.
  788.    There are surely many options to `tar', and three different style
  789. for writing them: mnemonic options, short options, and old options.
  790. These styles are discussed below.  Some options make sense with any
  791. main command, while others are meaningful only with particular main
  792. commands.  One option should state the main command, all others are
  793. truly optional.
  794.    Beware that `tar' options are case sensitive.  For example, {No
  795. Value For "List"} or {No Value For "List"} options are not equivalent to
  796. `--list' (`-t'), in fact, they do not even exist.  Options `-T' and
  797. `-t' are different options, the first requires an argument for stating
  798. the name of a file providing a list of NAMEs, the second does not
  799. require an argument and is another way to write `--list' (`-t').
  800.    Each NAME in the synopsis above is interpreted as an archive member
  801. name when the main command is one of `--compare' (`-d'), `--delete',
  802. `--extract' (`-x'), `--list' (`-t') or `--update' (`-u').  For all
  803. other main commands, NAMEs are interpreted as the names of files
  804. (including directories) in the file system.  `tar' interprets relative
  805. file names as being relative to the working directory.
  806.    `tar' will make all file names relative (by removing leading `/'s
  807. when archiving or restoring files), unless you specify otherwise (using
  808. the `--absolute-names' (`-P') option).
  809. FIXME: xref File Name
  810. Interpretation
  811.    , for more information about `--absolute-names' (`-P').
  812. FIXME: yet another node name that is probably wrong.
  813.    The distinction between file names and archive member names is
  814. especially important when shell globbing is used, and sometimes a
  815. source of confusion for newcomers.  "Globbing" is the operation by
  816. which "wildcard" characters, `*' or `?' for example, are replaced and
  817. expanded into all existing files matching the given pattern.  The
  818. problem is that shells may only glob using existing files in the file
  819. system.  Only `tar' may glob on archive members, so when needed, you
  820. must ensure that wildcard characters reach `tar' without being
  821. interpreted by the shell first.  Using a backslash before `*' or `?',
  822. or putting the whole argument between quotes, is usually sufficient for
  823. this.
  824.    Even if NAMEs are often specified on the command line, they can also
  825. be read from a text file in the file system, using the
  826. `--files-from=FILE-OF-NAMES' (`-T FILE-OF-NAMES') option.
  827.    Each of the following subsection groups some options under a common
  828. functionality.
  829.    You can use `tar' to store files in an archive, to extract them from
  830. an archive, and to do other types of archive manipulation.  The primary
  831. argument to `tar', which is called the "operation", specifies which
  832. action to take.  The other arguments to `tar' are either "options",
  833. which change the way `tar' performs an operation, or "file names",
  834. which specify the files `tar' is to act on.  The typical `tar' command
  835. line syntax is:
  836.    GNU `tar' returns only a few exit statuses.  I'm really aiming
  837. simplicity in that area, for now.  If you are not using the `--compare'
  838. (`-d') option, zero means that everything went well, besides maybe
  839. innocuous warnings.  Nonzero means that something went wrong.  Right
  840. now, as of today, "nonzero" is almost always 2, except for remote
  841. operations, where it may be 128.
  842. File: tar.info,  Node: Option Styles,  Next: Options,  Prev: Synopsis,  Up: Invoking tar
  843. Many Styles for Options
  844. =======================
  845. * Menu:
  846. * Mnemonic Options::
  847. * Short Options::
  848. * Old Options::
  849. * Mixing Styles::
  850. File: tar.info,  Node: Mnemonic Options,  Next: Short Options,  Prev: Option Styles,  Up: Option Styles
  851. Mnemonic Option Style
  852. ---------------------
  853.    Each OPTION has at least one mnemonic option name starting with two
  854. dashes in a row, v.g. `--list' (`-t').  The mnemonic option names are
  855. more legible than the corresponding short or old option names, you may
  856. prefer them if you highly praise clarity.  It sometimes happens that a
  857. single mnemonic option has many different different names, which are
  858. then synonymous.  In addition, mnemonic option names can be given unique
  859. abbreviations.  For example, `--cre' can be used in place of `--create'
  860. because there is no other mnemonic option which begins with `cre'.
  861.    Some options require an argument.  This is the case of the
  862. `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME') option, which tells the name
  863. of the `tar' archive.  The argument of a mnemonic option is usually
  864. given right after the option itself, and introduced by an equal sign.
  865. For example, the `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME') option is
  866. given the `archive.tar' file as argument by using the notation
  867. `--file=archive.tar' for the mnemonic option.
  868.    Mnemonic options are meant to be obvious and easy to remember,
  869. possibly more so than their corresponding short options, below.  For
  870. example:
  871.      tar --create --verbose --block-size=20 --file=/dev/rmt0
  872. gives a fairly good set of hints about what the command does, even for
  873. those not fully acquainted with `tar'.
  874. File: tar.info,  Node: Short Options,  Next: Old Options,  Prev: Mnemonic Options,  Up: Option Styles
  875. Short Option Style
  876. ------------------
  877.    Most options, but not all of them, also have a short option name
  878. starting with a single dash, and followed by a single character, v.g.
  879. `-t'.  In fact, `-t' is exactly the short option name for the mnemonic
  880. option `--list' (`-t'), both having exactly the same meaning.  The
  881. forms are absolutely identical in function.
  882.    The short option names are faster to type than mnemonic option names.
  883. All along this manual, whenever a mnemonic option name is given, its
  884. equivalent short option name follows between parentheses, if such a
  885. short option name exists.
  886.    Short options which require arguments use the immediately following
  887. argument, so it may be thought as being merely introduced right after
  888. it, usually separate by white space.  It is also possible to stick the
  889. argument right after the short option name, using no intervening space.
  890. So one might write `-f archive.tar' or `-farchive.tar' instead of
  891. using `--file=archive.tar'.  Both `--file=ARCHIVE-NAME' and
  892. `-f ARCHIVE-NAME' denote the option to give the archive a non-default
  893. name, which in the example is `archive.tar'.  When the option is given
  894. separately, its argument follows it, as is usual for Unix programs.
  895. For example:
  896.      tar -c -v -b 20 -f /dev/rmt0
  897.    Short options letters may be lumped together, but contrary to old
  898. options, they do not necessarily have to.  When short options are
  899. nevertheless coalesced, use a single dash for them all.  Only the last
  900. one in such a set is allowed to have an argument.  (Clustering many
  901. options, the last of which taking an argument, seems to be fairly
  902. opaque writing to me.  I would even like that GNU `getopt' be helpful
  903. enough to make this illegal.)
  904.    If you move short options in the command, be sure to move their
  905. arguments along with them, if any.
  906.