Re: help with quoting/expansion in bash
On Mon, Feb 13, 2006 at 11:45:14AM -0500, Daniel B. wrote:
> Mike Bird wrote:
>
> >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"
I would have done:
for i in 1 2 3; do
cd "dir $i"
pwd
cd ..
done
--
"The alternative is not plan or no plan. The question is: whose
planning? Should each member of society plan for himself or should
the paternal government alone plan for all?" -- Ludwig von Mises
Rick Pasotto rick@niof.net http://www.niof.net
Reply to: