find(1) behaving strange or do I miss something

Matthew Woehlke mw_triad@users.sourceforge.net
Tue Jul 10 21:23:00 GMT 2007


Ariel Burbaickij wrote:
> Hello all,
> following situation:
> I hate white spaces in file and cranked tiny bashscript for replacing
> them that goes like this:
> for i in `find . -type f`
> do
> mv $i /some_directory/`echo $i|sed 's/ /_/g'`
> done
> 
> On this I get complaints from mv that it cannot find files that are
> basically parts of the
> name with spaces like this:
> [snip]

Not that this has anything to do with Cygwin, but...
well, yes, because bash is splitting at whitespace :-).

You probably want something like this:
find <args> | while read i ; do mv "$i" "${i// /_}" ; done

(note that "$i" must be quoted also!)

-- 
Matthew
"What is a release plan, anyway?" -- Oswald Buddenhagen
   ...who I'm sure did not mean it seriously ;-)


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list