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

From: Jonathon Conte (thesicktwist@hotmail.com)
Date: Mon Apr 30 2007 - 20:01:05 EDT


>From: "Ian C. Blenke" <ian@blenke.com>
>Reply-To: slug@nks.net
>To: slug@nks.net
>Subject: Re: [SLUG] creating tar archive of filenames containing spaces
>Date: Mon, 30 Apr 2007 18:31:40 -0400
>
>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
>

Thanks for the tips guys! I appreciate your ideas and will probably make it
work using find. However, I'm still curious to know if I made wrong
assumptions about bash with the first method that I tried. Why does the
following syntax fail to correctly handle filenames containing spaces?

tar -cf ../archive.tar $(ls -Q *)

Jonathon

_________________________________________________________________
Don’t quit your job – Take Classes Online and Earn your Degree in 1 year.
Start Today!
http://www.classesusa.com/clickcount.cfm?id=866146&goto=http%3A%2F%2Fwww.classesusa.com%2Ffeaturedschools%2Fonlinedegreesmp%2Fform-dyn1.html%3Fsplovr%3D866144

-----------------------------------------------------------------------
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:15:17 EDT