On 06/01/11 12:30, Mike Williams wrote: > > > On Wed, Jun 1, 2011 at 3:18 PM, JD <jd1008@xxxxxxxxx > <mailto:jd1008@xxxxxxxxx>> wrote: > > On 06/01/11 12:05, Patrick O'Callaghan wrote: > > On Wed, 2011-06-01 at 09:59 -0700, JD wrote: > >> Since a space is Unix's and Linux's chosen field separator, > >> I think having a space in filenames should be avoided. there > >> are many situations where spaces in filenames cause problems. > >> A simple example: > >> > >> for i in *; do > >> [ -f $i ]&& echo $i is a file > >> done > >> > >> you will see that the file with spaces in it's name > >> will not be recognized as a file because each > >> space-separated member of that file name > >> becomes a separate argument > >> when * is expanded by the shell. > > > > No, each filename counts as one argument, even if it has spaces > in it. > > The problem arises when you *use* the argument. The above should > read: > > > > for i in *; do > > [ -f "$i"]&& echo "$i" is a file > > done > > > > (the quotes are optional in the echo case obviously). > > > > poc > > > The quotes are not optional. > > I think he meant that the quotes are optional for the echo $i - which > is correct. > > Personally I avoid spaces in filenames and usually use a perl one > liner to substitute an underscore for spaces when I don't have to keep > the original name for someone else. > > zsh works without any quotes, the first example works fine for files > with spaces in the names with zsh. > > Mike > Nop! They are not optional for the "use" of the value of the variable, as I clearly demonstrated above. -- users mailing list users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines