简体   繁体   English

在linux中查找具有名称条件的非空目录

[英]Find non empty directories with condition on their names in linux

There's a directory that has several subdirectories.有一个目录有几个子目录。 These subdirectories' names are the date that the subdirectory was created.这些子目录的名称是子目录的创建日期。 Now I want to list the subdirectories created in 'June' of 2021 and are not empty, so their names all contain this: 202106*.现在我要列出2021年“六月”创建的子目录,并且不为空,所以它们的名字都包含这个:202106*。 How can I do this?我怎样才能做到这一点? The command I use to list non-empty directories is this:我用来列出非空目录的命令是这样的:

find . -mindepth 1 -maxdepth 1 -not -empty -type d

But I don't know how to set the name condition.但我不知道如何设置名称条件。

The name is specified by -name名称由-name指定

find . -mindepth 1 -maxdepth 1 -not -empty -type d -name '202106*'

For more information read the find man page有关更多信息,请阅读查找手册页

建议

find . -type d -path "*202106*" -not -empty

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM