The difference between "find -delete" and "rm -rf"?

I want to recursively delete files from a specific directory. So i used

find . -wholename "*.txt" -delete

We can also delete files using

rm -rf *.txt

What is the difference between deleting a file with rmand find??

+5
source share
3 answers

find . -wholename abd.txt -deletetrying to delete all files with a name abd.txtthat are located somewhere in the directory tree.

rm -rf abd.txttrying to delete abd.txt, and if it is a directory, all files and directories in the whole tree.

+5
source

find -wholename GLOBPATTERN ( ), glob, rm, ( 1) .

Btw. -r rm, (- .txt , )

+3

find -delete, . find , -delete , . , ,

While the command rm -rfrecursively deletes files / directories no matter what. This means that it rmwill delete all files and directories in a specific path. -rmeans recursion, and -f- forced removal. Therefore, rmin conjunction with -rfwill continue to delete directories and files in directories on the target path until it finds more.

+1
source

All Articles