How to change spaces in filenames



I would like to change all spaces in filename to dashes but can't
seem to get it working. The sed part works ok.

cd target_tree
for name in "`find . -maxdepth 99`"; do
mv "$name" "$name" | sed 's/\ /-/g'
done

When testing the above with replacement echo statements, I get the
strange result that the the word "command_is" only occurs once at the
beginning of the $name list and the final sed command never appears at
all.

do
echo "command_is "$name" `"$name" |sed '/\ /-/g'`"
done


I also tried with tr but cannot figure out how to make tr operate on
my $name variable - it seems to insist on a file.

Larry

--
My real sig is much better.
.



Relevant Pages

  • File name problem
    ... I found that if I do a select from .csv file, it won't work if the filename ... Dim ConStr As String = _ ... If I replace 1st 2 periods and dashes with underscores it works fine. ...
    (microsoft.public.dotnet.languages.vb)
  • File name problem
    ... I found that if I do a select from .csv file, it won't work if the filename ... Dim ConStr As String = _ ... If I replace 1st 2 periods and dashes with underscores it works fine. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: replacing
    ... Why following sed command is failing? ... I want to substitute quotes in the end of line with nothing. ... sed l < filename ...
    (comp.unix.shell)