How do I handle spaces in a script that uses the results of find in a for loop?
I am trying to write a simple command that searches through a music directory for all files of a certain type and copies them to a new directory. I would be fine if the files didn't h开发者_StackOverflow中文版ave spaces.
I'm using a script from the following question, but it fails for spaces: bash script problem, find , mv tilde files created by gedit
Any suggestions on how I can handle spaces, once I'm satisfied that all the files are being listed, I'll change echo
to cp
for D in `find . -name "*.wma*"`; do echo "${D}"; done
You probably want to do this instead:
find . -name *.wma -exec echo "{}" \;
精彩评论