find -mindepth -prune conflict? -
i have dir structure like:
gameplay/ch1_of_182/ajax.googleapis.com/... gameplay/ch1_of_182/platform.twitter.com/... gameplay/ch1_of_182/privacy-policy.truste.com/... gameplay/ch1_of_182/www.facebook.com/... gameplay/ch1_of_182/www.gameplay.com/... gameplay/ch1_of_182/www-mega.gameplay.com/... gameplay/ch2_of_182/ajax.googleapis.com/... gameplay/ch2_of_182/platform.twitter.com/... gameplay/ch2_of_182/privacy-policy.truste.com/... gameplay/ch2_of_182/www.facebook.com/... gameplay/ch2_of_182/www.gameplay.com/... gameplay/ch2_of_182/www-mega.gameplay.com/... ... gameplay/ch182_of_182/ajax.googleapis.com/... gameplay/ch182_of_182/platform.twitter.com/... gameplay/ch182_of_182/privacy-policy.truste.com/... gameplay/ch182_of_182/www.facebook.com/... gameplay/ch182_of_182/www.gameplay.com/... gameplay/ch182_of_182/www-mega.gameplay.com/...
created using wget. want delete of directories , files contain except 2 directories "gameplay.com" in name.
i have been trying different variants of:
find . -mindepth 2 ! -path "*gameplay.com" -prune -exec rm -r {} \;
but without luck.
when run gameplay parent dir, 4 of 6 directories in each of 182 directories (actually using 1 testing purposes) not contain "gameplay.com" name pattern deleted along contents, desired. , although 2 directories contain "gameplay.com" name pattern left undeleted, files contained within each deleted, not good.
i thought -prune
option supposed let find
know ignore directory specified, must specifying wrong, because not happening, leaving me 2 empty directories in each of 182 parent dirs.
i think there potential conflict -mindepth
, -prune
options, because running command gameplay parent directory, without 182 child directories, each containing 2 directories want left in tact, deleted.
i guess write for
loop cycle thru each dir, seems me find
should able accomplish task in 1 foul swoop if doesn't mind shedding light how.
logically, find . -mindepth 2 \( ! -path "*gameplay.com" \) -a \( -prune \) -a \( -exec rm -r {} \; \)
so since -prune
comes after path check, it's never gotten if path check false. try switching order.
find . -mindepth 2 -prune ! -path "*gameplay.com" -exec rm -r {} \;
Comments
Post a Comment