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

help with quoting/expansion in bash



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.

--Dave

Reply to: