[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash and variable holding directories with spaces



On Sat, Dec 03, 2005 at 05:58:28PM -0500, H.S. wrote:
> Michael Marsh wrote:
> > If I understand the behavior you want correctly, then
> > DIRS="'/cygdrive/c/Documents\ and\ Settings /cygdrive/d/My\ Data'"
> > works for me.
> > 
> > This also works for constructions like
> > DIRS="'$dir1 $dir2'"
> 
> Okay, but this doesn't work:
> 
> $> ls -nl file*
> -rw-------  1 1000 1000 0 2005-12-03 16:56 file 1
> -rw-------  1 1000 1000 0 2005-12-03 16:56 file 2
> 
> $> DIRS="'file\ 1 file\ 2'"; ls -ln $DIRS
> ls: 'file\: No such file or directory
> ls: 1: No such file or directory
> ls: file\: No such file or directory
> ls: 2': No such file or directory
> 
> $> DIRS="'file\ 1 file\ 2'"; ls -ln "$DIRS"
> ls: 'file\ 1 file\ 2': No such file or directory

in this case you probably want

$ DIRS='file\ 1 file\ 2';  eval ls -ln $DIRS


Almut



Reply to: