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

Cheers.

Andrzej

AndrzejL

"Never meet Your heroes. Most of the time you'll only end up disappointed." White Polak Male Husband Employee Hetero Carnivorous Fugly Geek @$$hole with ADD Catholic “Some men just want to watch the world burn.”

Comments are closed.