From owner-freebsd-questions@FreeBSD.ORG Sat Aug 23 14:57:54 2008 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E7F71065679 for ; Sat, 23 Aug 2008 14:57:54 +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 DE9A38FC15 for ; Sat, 23 Aug 2008 14:57:53 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r55.edvax.de (port-92-195-101-165.dynamic.qsc.de [92.195.101.165]) by mx02.qsc.de (Postfix) with ESMTP id 6A36316C003B; Sat, 23 Aug 2008 16:57:50 +0200 (CEST) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id m7NEvmlF050307; Sat, 23 Aug 2008 16:57:49 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sat, 23 Aug 2008 16:57:48 +0200 From: Polytropon To: Thomas Dickey Message-Id: <20080823165748.539fe7b9.freebsd@edvax.de> In-Reply-To: <20080823141636.GA439@saltmine.radix.net> References: <20080823101941.GA42601@skytracker.ca> <20080823160957.22e6254f.freebsd@edvax.de> <20080823141636.GA439@saltmine.radix.net> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: questions@freebsd.org Subject: Re: space char shell script problem 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: Sat, 23 Aug 2008 14:57:54 -0000 On Sat, 23 Aug 2008 10:16:36 -0400, Thomas Dickey wrote: > spaces won't go away, and since they're legal in filenames, one may as > well handle them. Well, it's completely possible to create a file name like: This is my *favourite* photo from "Cats" \ by Bob & Jane / my wife ~ 2008 `musical'.JPG What a fun handling this. :-) Call me old fashioned, but I don't mind making things more complicated than it should be. The space character is the command argument separator, as well as / is the root directory and * is "everything". Applications like xmms can even replace the _ by a space when showing the filename of an mp3 file (given that no ID3 tag is provided). So I avoid spaces generally, and when I get files with spaces, I do convert the names automatically. > A script like > > #!/bin/sh > for x in "$@" > do > echo $x > done > > handles quoting nicely enough (for spaces, anyway). ls will translate > some non-printing characters to printable; the 'find' program is a better > alternative if one must derive the list inside the program. That's correct; find can provide file names including paths and can furthermore explude directories from being in the list (-type f). In your script, $x contains the filename with spaces and should be passed as one value to the program called. -- Polytropon >From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...