Re: [SLUG] creating tar archive of filenames containing spaces

From: Ian C. Blenke (ian@blenke.com)
Date: Mon Apr 30 2007 - 18:31:40 EDT


Eben King wrote:

>I hope "find" doesn't spit out more filenames than
>can go in "tar"'s argument list, because then xargs
>will run tar again and it'll overwrite the existing
>archive with the next batch. IIRC tar has an option
>like "take names from filename" (-T?). Might "find
>... | tar ... -T -" do what you want? Sorry if I'm
>off base; my Linux box is down for a few days.
>
>

Very true. You can also use "--null" to accept null terminated names, ie:

    find . -print0 | tar cf ../test.tar -T - --null

Which, like find -print0 and xargs -0, allows tar to accept a null
terminated list of filenames.

Not that I think you need --null there, as each filename is already on a
separate line, right?

Then again, you can theoretically have newlines in a filename... (hooray
sentinel values!)

>>You could also just tar up the entire directory:
>>
>> tar cf ../test.tar .
>>
>>Another option is to temporarily redefine IFS.
>>
>>
>
>"/" can't occur in filenames.
>
>

Er? You referring to "../test.tar"? That means "test.tar in the parent
directory"

If you're referring to absolute vs relative filenames inside a tar file,
that's a different issue.

- Ian

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:14:59 EDT