[Discuss] bash problem

pw p.willis at telus.net
Thu Aug 16 15:33:17 PDT 2007


#!/bin/bash

export START=`pwd`

for DIR in `find -type d`; do
	cd $DIR;
	cd $START;
done

#END IF SCRIPT



The code above works fine as long as there are no
spaces in $DIR .

How can I ensure that bash changes into
directories where the path contains spaces?

So far I've tried:

cd "$DIR"

and:

DIR=`echo $DIR | sed -e "s/\ /\\\ /g"`
cd $DIR


Any thoughts?

Peter



More information about the Discuss mailing list