tar: files
1
1 6.3 Reading Names from a File
1 =============================
1
1 Instead of giving the names of files or archive members on the command
1 line, you can put the names into a file, and then use the
1 '--files-from=FILE-OF-NAMES' ('-T FILE-OF-NAMES') option to 'tar'. Give
1 the name of the file which contains the list of files to include as the
1 argument to '--files-from'. In the list, the file names should be
1 separated by newlines. You will frequently use this option when you
1 have generated the list of files to archive with the 'find' utility.
1
1 '--files-from=FILE-NAME'
1 '-T FILE-NAME'
1 Get names to extract or create from file FILE-NAME.
1
1 If you give a single dash as a file name for '--files-from', (i.e.,
1 you specify either '--files-from=-' or '-T -'), then the file names are
1 read from standard input.
1
1 Unless you are running 'tar' with '--create', you cannot use both
1 '--files-from=-' and '--file=-' ('-f -') in the same command.
1
1 Any number of '-T' options can be given in the command line.
1
1 The following example shows how to use 'find' to generate a list of
1 files smaller than 400K in length and put that list into a file called
1 'small-files'. You can then use the '-T' option to 'tar' to specify the
1 files from that file, 'small-files', to create the archive 'little.tgz'.
11 (The '-z' option to 'tar' compresses the archive with 'gzip'; ⇒
gzip for more information.)
1
1 $ find . -size -400 -print > small-files
1 $ tar -c -v -z -T small-files -f little.tgz
1
1 By default, each line read from the file list is first stripped off any
1 leading and trailing whitespace. If the resulting string begins with
1 '-' character, it is considered a 'tar' option and is processed
1 accordingly(1). For example, the common use of this feature is to
1 change to another directory by specifying '-C' option:
1
1 $ cat list
1 -C/etc
1 passwd
1 hosts
1 -C/lib
1 libc.a
1 $ tar -c -f foo.tar --files-from list
1
1 In this example, 'tar' will first switch to '/etc' directory and add
1 files 'passwd' and 'hosts' to the archive. Then it will change to
1 '/lib' directory and will archive the file 'libc.a'. Thus, the
1 resulting archive 'foo.tar' will contain:
1
1 $ tar tf foo.tar
1 passwd
1 hosts
1 libc.a
1
1 Note, that any options used in the file list remain in effect for the
1 rest of the command line. For example, using the same 'list' file as
1 above, the following command
1
1 $ tar -c -f foo.tar --files-from list libcurses.a
1
1 will look for file 'libcurses.a' in the directory '/lib', because it was
1 used with the last '-C' option (⇒Position-Sensitive Options).
1
1 If such option handling is undesirable, use the
1 '--verbatim-files-from' option. When this option is in effect, each
1 line read from the file list is treated as a file name. Notice, that
1 this means, in particular, that no whitespace trimming is performed.
1
1 The '--verbatim-files-from' affects all '-T' options that follow it
1 in the command line. The default behavior can be restored using
1 '--no-verbatim-files-from' option.
1
1 To disable option handling for a single file name, use the
1 '--add-file' option, e.g.: '--add-file=--my-file'.
1
1 You can use any GNU 'tar' command line options in the file list file,
1 including '--files-from' option itself. This allows for including
1 contents of a file list into another file list file. Note however, that
1 options that control file list processing, such as
1 '--verbatim-files-from' or '--null' won't affect the file they appear
1 in. They will affect next '--files-from' option, if there is any.
1
Menu