Date: Sat, 23 Aug 2008 16:57:48 +0200 From: Polytropon <freebsd@edvax.de> To: Thomas Dickey <dickey@radix.net> Cc: questions@freebsd.org Subject: Re: space char shell script problem 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>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 23 Aug 2008 10:16:36 -0400, Thomas Dickey <dickey@radix.net> 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, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080823165748.539fe7b9.freebsd>