find
doesn't care about special characters in file names, but the program that's parsing the output of find
might. If you're using xargs
, use the -print0
option to find
, and the -0
option to xargs
. This tells find
and xargs
to use null characters (which cannot appear in file names) as a separator between file names, and xargs
not to do any other parsing which would mangle file names containing spaces.
find /media/media1/HDTV -name '*.nfo' -type f -print0 |
xargs -0 sed -i 's/pattern/replacement/'
Another way to invoke a command on many files is to use find
only.
find /media/media1/HDTV -name '*.nfo' -type f -exec sed -i 's/pattern/replacement/' {} +
find
, it doesn't care about special characters in file names. The problem is with what you do with thefind
output. Post the complete command that you tried, and explain exactly what you want to do with the files. – Gilles 'SO- stop being evil' Jun 09 '12 at 12:05