On 10/19/2011 05:05 PM, e-letter wrote:
Readers,

I tried without success the following command syntax

tar --extract --file=/path/to/tarball<  /path/to/list/of/files.txt

Your question is about tar and/or the shell, neither of which are part of coreutils. You may have better results by asking your question on a more appropriate list. That said...


To my surprise this failed. If the 'files.txt' contained:

text1 text2 text3

The command syntax is successful for:

tar --extract --file=/path/to/tarball text1 text2 text3

Is there a reason why redirect does not work with tar command?

If you want the contents of files.txt to be passed as command line arguments, then you need to use command substitution, not file redirection:

tar --extract --file=/path/to/tarball $(cat /path/to/list/of/files.txt)

On the other hand, if you want tar to read a list of file names from a file stdin rather than from command line arguments, you need to use the correct tar option:

tar --extract --file=/path/to/tarball --files-from=/path/to/list/of/files.txt

Or if you insist on using redirection, then use '-' as the --files-from argument to tell tar to read from stdin:

tar --extract --file=/path/to/tarball --files-from=- </path/to/list/of/files.txt

--
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to