tar: create dir
1
1 2.6.5 Archiving Directories
1 ---------------------------
1
1 You can archive a directory by specifying its directory name as a file
1 name argument to 'tar'. The files in the directory will be archived
1 relative to the working directory, and the directory will be re-created
1 along with its contents when the archive is extracted.
1
1 To archive a directory, first move to its superior directory. If you
1 have followed the previous instructions in this tutorial, you should
1 type:
1
1 $ cd ..
1 $
1
1 This will put you into the directory which contains 'practice', i.e.,
1 your home directory. Once in the superior directory, you can specify
1 the subdirectory, 'practice', as a file name argument. To store
1 'practice' in the new archive file 'music.tar', type:
1
1 $ tar --create --verbose --file=music.tar practice
1
1 'tar' should output:
1
1 practice/
1 practice/blues
1 practice/folk
1 practice/jazz
1 practice/collection.tar
1
1 Note that the archive thus created is not in the subdirectory
1 'practice', but rather in the current working directory--the directory
1 from which 'tar' was invoked. Before trying to archive a directory from
1 its superior directory, you should make sure you have write access to
1 the superior directory itself, not only the directory you are trying
1 archive with 'tar'. For example, you will probably not be able to store
1 your home directory in an archive by invoking 'tar' from the root
1 directory; ⇒absolute. (Note also that 'collection.tar', the
1 original archive file, has itself been archived. 'tar' will accept any
1 file as a file to be archived, regardless of its content. When
1 'music.tar' is extracted, the archive file 'collection.tar' will be
1 re-written into the file system).
1
1 If you give 'tar' a command such as
1
1 $ tar --create --file=foo.tar .
1
1 'tar' will report 'tar: ./foo.tar is the archive; not dumped'. This
1 happens because 'tar' creates the archive 'foo.tar' in the current
1 directory before putting any files into it. Then, when 'tar' attempts
1 to add all the files in the directory '.' to the archive, it notices
1 that the file './foo.tar' is the same as the archive 'foo.tar', and
1 skips it. (It makes no sense to put an archive into itself.) GNU 'tar'
1 will continue in this case, and create the archive normally, except for
1 the exclusion of that one file. (_Please note:_ Other implementations
1 of 'tar' may not be so clever; they will enter an infinite loop when
1 this happens, so you should not depend on this behavior unless you are
1 certain you are running GNU 'tar'. In general, it is wise to always
1 place the archive outside of the directory being dumped.)
1