-1

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*. 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.

  • Does this answer your question? [How can I recursively find all files in current and subfolders based on wildcard matching?](https://stackoverflow.com/questions/5905054/how-can-i-recursively-find-all-files-in-current-and-subfolders-based-on-wildcard) – Mime May 17 '22 at 14:16

2 Answers2

1

The name is specified by -name

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

For more information read the find man page

Mime
  • 1,142
  • 1
  • 9
  • 20
1

suggesting

find . -type d -path "*202106*" -not -empty
Dudi Boy
  • 4,551
  • 1
  • 15
  • 30