You can pipe the output from find
into xargs
, specifying that only newlines should be considered as delimiters between filenames:
find -name '*.exe' | xargs -d \\n rm
The more portable way to do this is to use the null character as the delimiter:
find -name '*.exe' -print0 | xargs -0 /bin/rm
See find
's manpage for an example that does this.
Another option is to use the command you used, but to set bash's internal argument delimiter to newlines-only:
IFS=$'\n'; rm $(find . -name "*.exe");
Here the $'...'
quoting construct is used to create a newline character. This approach will be less resilient in the case of a long list of filenames than will using xargs
.