You are doing everything right. It is the '*' that gives you a problem (the shell is expanding it into list of files instead of the find
). The right syntax could be:
cd <your_directory>; find . -type f | xargs rm -f
find <your_directory> -type f | xargs rm -f
(The latter is a bit less efficient since it will pass longer names to xargs
, but you will hardly notice :-) )
Alternatively, you could escape your '*' like this (however in that case it will also try also remove "." and ".."; it is not a biggie - you will just get a little warning :-) ):
find . -name '*' | xargs rm -f
find . -name "*" | xargs rm -f
find . -name \* | xargs rm -f
If your file names contain spaces then use this:
find . -type f -print0 | xargs -0 rm -f