I need a script to find directories in a tree and cd to them. Some of the directory names have blanks in them, eg "Flash Player". So if a directory has the subdirectories

./Flash Player
./foo

then a command like


IFS=./; for directory in `find ./ -type d | xargs`

will give
directory="Flash Player "
then
directory="foo "

in bash to cd to "Flash Player " I have to cd to "Flash\ Player ". I can substitute the first blank with

directory=${directory//\ /\\}

but there is a 2nd blank in the directory name and I get

directory="Flash\ Player\ "

In this construct the $ symbol does not work as an EOL symbol, so I can't selectively remove the last blank. I tried substituting the blanks between [:alphanum:] [:alphanum:] but there doesn't seem to be any way to replace the char you matched (here the 'h' and the 'P') as you can in perl.

Any ideas on changing "Flash Player " to "Flash\ Player"
(or "Flash\ Player ") in a bash script?

Thanks Joe

--
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
--
TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ  : http://trilug.org/faq/
TriLUG Member Services FAQ : http://members.trilug.org/services_faq/

Reply via email to