0

I want to delete certain files within my subfolders but not in the current folder. find offers a neat method to do that:

How can I recursively delete all files of a specific extension in the current directory?

for example

find . -name "*.bak" -type f -delete

but so far I only found instructions on how to delete everything in the current + all subfolders. Is there a way to perform this action only on the subfolders without cd into each subfolder?

And
  • 103

1 Answers1

3

Use -mindepth 2

find . -mindepth 2 -name "*.bak" -type f -delete
pLumo
  • 26,947