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

Re: help with quoting/expansion in bash



On Sun, 2006-02-12 at 11:23, David Berg wrote:
> I'm trying to write a for loop that descends into a list of
> directories and runs a command.  I can't seem to get the quoting right
> though.  Most of the directories have spaces and they are making
> things difficult for me.  Here is what I have:
> 
> for DIR in dir\ 1 dir\ 2 dir\ 3; do
>         cd $DIR
>         pwd
>         cd ..
> done
> 
> The spaces in $DIR aren't escaped.
> 
> Any help, including a pointer to the relevant part of TFM, is much appreciated.

cd "$DIR"

--Mike Bird



Reply to: