How to find all the empty folders inside a current folder using terminal? How to filter the output of the command to only show folders that name DOES NOT matches a certain pattern?

Hi.

How to find all the empty folders inside a current folder using terminal? How to filter the output of the command to only show folders that name DOES NOT matches a certain pattern?

It’s simple:

find . -depth -type d -empty | grep -i -v -e "pattern"

You can filter out more then one pattern:

find . -depth -type d -empty | grep -i -v -e "pattern1" -e "pattern2" -e "pattern3" -e "pattern4"

This command will find all the empty folders in the current (.) folder and will grep (ignoring the UPPER or lower case) for names that DO NOT match the pattern word and will display only those names.

Regards.

Andy

Advertisements