Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Yes, I had this in mind but I avoided using it due to the initial requirements. Question was edited and this works now because "the rules/ subfolders have no other subfolders." otherwise with subdirs, a file like ./somedir/rules/noway/somefile.pdf would be deleted even if it's not in rules but in one of its children so in that case prolly something like find . -path '*/rules/*/*' -prune -o -path '*/rules/*.pdf' -delete Anyway, you get my vote. As to in bash you can get away without quoting {} - only a couple of shells need that Commented Mar 16, 2016 at 18:57
  • Why -exec rm with all the parsing pitfalls and race conditions waiting to happen instead of -delete? Commented Mar 16, 2016 at 19:55
  • @Caleb - would you mind elaborating a bit on the first part ? What "parsing pitfalls" are we talking about when using find with -exec rm {} ? Commented Mar 16, 2016 at 21:22