From owner-freebsd-questions@FreeBSD.ORG Sun Nov 6 14:35:09 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73F90106566B for ; Sun, 6 Nov 2011 14:35:09 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id 385DD8FC13 for ; Sun, 6 Nov 2011 14:35:09 +0000 (UTC) Received: from r56.edvax.de (port-92-195-104-16.dynamic.qsc.de [92.195.104.16]) by mx02.qsc.de (Postfix) with ESMTP id CD6B61EAA2; Sun, 6 Nov 2011 15:35:06 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id pA6EZ6ta002040; Sun, 6 Nov 2011 15:35:06 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Sun, 6 Nov 2011 15:35:06 +0100 From: Polytropon To: Chris Message-Id: <20111106153506.5c1bc8ac.freebsd@edvax.de> In-Reply-To: References: Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: recursive copy with spaces in descendants X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 14:35:09 -0000 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, ...