[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3.1 NUL-Terminated File Names

The `--null' option causes `--files-from=file-of-names' (`-T file-of-names') to read file names terminated by a NUL instead of a newline, so files whose names contain newlines can be archived using `--files-from'.

`--null'

Only consider NUL-terminated file names, instead of files that terminate in a newline.

`--no-null'

Undo the effect of any previous `--null' option.

The `--null' option is just like the one in GNU xargs and cpio, and is useful with the `-print0' predicate of GNU find. In tar, `--null' also disables special handling for file names that begin with dash.

This example shows how to use find to generate a list of files larger than 800K in length and put that list into a file called `long-files'. The `-print0' option to find is just like `-print', except that it separates files with a NUL rather than with a newline. You can then run tar with both the `--null' and `-T' options to specify that tar gets the files from that file, `long-files', to create the archive `big.tgz'. The `--null' option to tar will cause tar to recognize the NUL separator between files.

 
$ find . -size +800 -print0 > long-files
$ tar -c -v --null --files-from=long-files --file=big.tar

The `--no-null' option can be used if you need to read both NUL-terminated and newline-terminated files on the same command line. For example, if `flist' is a newline-terminated file, then the following command can be used to combine it with the above command:

 
$ find . -size +800 -print0 |
  tar -c -f big.tar --null -T - --no-null -T flist

This example uses short options for typographic reasons, to avoid very long lines.

GNU tar lists, so in many cases it is safe to use them even without the `--null' option. In this case tar will print a warning and continue reading such a file as if `--null' were actually given:

 
$ find . -size +800 -print0 | tar -c -f big.tar -T -
tar: -: file name read contains nul character

The null terminator, however, remains in effect only for this particular file, any following `-T' options will assume newline termination. Of course, the null autodetection applies to these eventual surplus `-T' options as well.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on July, 28 2014 using texi2html 1.76.