mv xrags and cp

Heike C. Zimmerer nospam06q3 at gmx.net
Sat Jan 20 19:08:55 UTC 2007


Florian Diesch <diesch at spamfence.net> writes:

> See my answer to the same mail.
>
>
> If you want do it with a loop use a  while loop:
>
>  find olddir -name '*.jpg | while read fname; do
>    do_something_with_file $fname
>  done
>
> This works as long as there's no linebreak in a filename


Nope.

>  find olddir -name '*.jpg | while read fname; do

breaks on leading white space (typo ignored),

>    do_something_with_file $fname

breaks on any white space whatsoever.

find olddir -name '*.jpg' | while IFS= read fname; do
   do_something_with_file "$fname"
done

or use the canonical version which imposes no restrictions at oll on
file names:

find olddir -name '*.jpg' -exec do_something_with {} \;






More information about the ubuntu-users mailing list