Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Nov 2011 15:35:06 +0100
From:      Polytropon <freebsd@edvax.de>
To:        Chris <cpuburner@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: recursive copy with spaces in descendants
Message-ID:  <20111106153506.5c1bc8ac.freebsd@edvax.de>
In-Reply-To: <CAKFHi=_W_sC-agEEpq%2Bco9MvvqBt1Ee3W8VEtL-sKwkYa-7yAg@mail.gmail.com>
References:  <CAKFHi=_W_sC-agEEpq%2Bco9MvvqBt1Ee3W8VEtL-sKwkYa-7yAg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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
http://www.dwheeler.com/essays/filenames-in-shell.html

David A. Wheeler:
Fixing Unix/Linux/POSIX Filenames:
Control Characters (such as Newline), Leading Dashes, and Other Problems
http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html

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.

Good luck!



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111106153506.5c1bc8ac.freebsd>