Shell Scripting: Using bash with xargs Shell Scripting: Using bash with xargs shell shell

Shell Scripting: Using bash with xargs


Try using:

find . -name vmware-*.log -print0 | xargs -0 rm

This causes find to output a null character after each filename and tells xargs to break up names based on null characters instead of whitespace or other tokens.


Do not use xargs. Find can do it without any help:

find . -name "vmware-*.log" -exec rm '{}' \;


Check out the -0 flag for xargs; combined with find's -print0 you should be set.

find . -name vmware-*.log -print0 | xargs -0 rm