[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: input/output redirection with tar
From: |
Eric Blake |
Subject: |
Re: input/output redirection with tar |
Date: |
Wed, 19 Oct 2011 17:11:47 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.4 Thunderbird/3.1.15 |
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 address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org