OT: Need help from bash experts...
Sorry for OT posting; I am not sure if there is a newsgroups for bash
experts, so I figured I'd try here.
I need to be able to write a bash script that can copy files from a directory
who's name includes a space (long story, but it's a windows directory under
Win98 on a machine on my network).
Anyway, supposing that the directory is "/mount/windows/spaced name" and I
need to copy all of the files in the directory to a target.
At a bash prompt, I can issue either:
cp "/mount/windows/spaced name/*" target
cp /mount/windows/spaced\ name/* target
and all works fine.
However, from within a bash script, something like:
cp $sourcedir/* target
fails, because the space isn't properly passed to cp, AND further the shell
doesn't do expansion on the wild card in the file name.
I have tried all sorts of variants:
and the cp command with various quotes and not quotes, and cannot seem to get
this to work. Within the script, if I try:
the first echo shows that there is no expansion of the wild card, while the
second echo works as expected, echoing the name of every file in
Clearly the problem is that dreadful space in the directory name. Any help on
how to syntax this greatly appreciated.