Skip to content

find

recursively find all files or directories to delete using find

### files
find . -type f -name file.txt -delete

### directories
find . -type d -name file.txt -delete

### both (print first)
find -type f -name grep.md -or -type d -name net

### delete
find -type f -name grep.md -delete -or -type d -name net -delete

Warning

no recovery is possible

Note

non-empty directories cannot be deleted

recursively find all files or directories to delete using find and xargs

find -type f -name index.md -or -type d -name net | xargs -I xxx echo xxx

Warning

no recovery is possible

Note

instead of echo you can use rm -fr even deleting non-empty directories

supper fast version with parallel execution using -P 0

find -type f -name index.md -or -type d -name net | xargs -P0 -I xxx echo xxx