recursive copy with spaces in descendants
freebsd at edvax.de
Sun Nov 6 14:35:09 UTC 2011
On Sat, 5 Nov 2011 15:47:20 -0400, Chris wrote:
> I'm having difficulty copying a directory tree from my FreeBSD server to
> USB storage. The problem is that the tree contains file and folder names
> which have spaces, similar to the following:
The thing you're intending to name are properly
called directories, not "folders". :-)
> ./foo bar/some name.tar.gz
> ./foo bar/child dir/some other name.tar.gz
> I've tried various combinations of cp with enclosing the top level
> directory in quotations, along with other commands like tar or xargs to no
> avail. The problem seems to be with creating the destination directories
> and folders, where mkdir/cp terminates with an invalid argument response.
That's a typical problem caused by those who put
spaces into filenames: Scripting requires more work
to do what you intend.
I may point you to the following articles that
deal with the _result_ of your problem:
David A. Wheeler
Filenames and Pathnames in Shell: How to do it correctly
David A. Wheeler:
Fixing Unix/Linux/POSIX Filenames:
Control Characters (such as Newline), Leading Dashes, and Other Problems
However, if you _can_, solve the _cause_ of your
problem, i. e. educate those who create that
kind of trouble-carrying file and directory names
_not_ to use spaces!
> Any ideas would be greatly appreciated, since I'm pretty much out of them
> at this point.
The articles should help you to deal with the problem,
as they present properly working solutions.
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions