Gordon Messmer
2016-Feb-03 18:28 UTC
[CentOS] delete directories with find and exclude other directories
On 02/03/2016 10:11 AM, m.roth at 5-cent.us wrote:> find . -type d ! -name logs -pruneThat will prune all of the directories whose name is not "logs", starting with "." So... not terribly useful.
m.roth at 5-cent.us
2016-Feb-03 18:51 UTC
[CentOS] delete directories with find and exclude other directories
Gordon Messmer wrote:> On 02/03/2016 10:11 AM, m.roth at 5-cent.us wrote: >> find . -type d ! -name logs -prune > > That will prune all of the directories whose name is not "logs", > starting with "." > > So... not terribly useful.Right, but a) I think I tried using prune 20 years ago... and b) I thought the o/p wanted to not deal with any directory whose name was logs. leaving off prune would get everything, which is perhaps a bit more useful. mark
Gordon Messmer
2016-Feb-03 19:29 UTC
[CentOS] delete directories with find and exclude other directories
On 02/03/2016 10:51 AM, m.roth at 5-cent.us wrote:> Right, but a) I think I tried using prune 20 years ago... and b) I thought > the o/p wanted to not deal with any directory whose name was logs. leaving > off prune would get everything, which is perhaps a bit more useful.I think you don't understand. I was pointing out that the command you specified would print the name '.' and that is all. It won't descend through '.' because you told it to prune all directories not named "logs". That is, I'm trying to point out that it's your *logic* that's flawed. OP was right in his thinking. The correct way to approach the problem is to ignore (prune) the logs dir, and then to do something with the remaining directories.