How to do a for loop of filenames with spaces using find

find -name "*.avi" -print0 | xargs -0 -n 1 echo

You don't have to echo in xargs:

find -name "*.avi" -print0 | xargs -0 -n 1 ./myscript

Also: find -name "*.avi" -exec ./myscript '{}' \;

Womble's answer definitely works in the majority of cases, but Xargs isn't perfect with spaces across all implementations. I've never found find's 'exec' mode to break. Solaris was particularly cranky in that respect.

Obviously, the '-print' would be better for simply generating output for a list of files in a for loop. But if you're running a command on a list of files, it's more efficient to just run the '-exec' option.