I have large tree, with many pdf
files in it. I want to delete the pdf
files in this tree, but only those pdf
files in sub folders named rules/
There are other type of files inside rules/
. The rules/
subfolders have no other subfolders.
For example, I have this tree. Everything below 'source'
source/
A/
rules/*.pdf, *.txt, *.c,etc..
etc/
B/
keep_this.pdf
rules/*.pdf
whatever/
C/
D/
rules/*.pdf
something/
and so on. There are pdf
files all over the place, but I only want to delete all the pdf
files which are in folders called rules/
and no other place.
I think I need to use
cd source
find / -type d -name "rules" -print0 | xargs -0 <<<rm *.pdf?? now what?>>>
But I am not sure what to do after getting list of all subfolders named rules/
Any help is appreciated.
On Linux mint.
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 inrules
but in one of its children so in that case prolly something likefind . -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 – don_crissti Mar 16 '16 at 18:57find
with-exec rm {}
? – don_crissti Mar 16 '16 at 21:22