Wednesday, November 12, 2008

List empty directories using find in bash


Linux command find gives an option called "empty" using which we can list empty regular files or empty directories.

e.g.

To list all the empty directories

$ find . -type d -empty

Output:

./bdb/prac
./sim/old/data
./prac/testdir

Related post:

- find file names with only digits, no text
- Use logical operator with linux find command
- exclude directory from find command

2 comments:

atoztoa said...

The problem with lots of us is that, we never even read the --help page for a command.

I never knew there was -empty for find, lol ;)

_ATOzTOA
www.atoztoa.com

Jadu Kumar Saikia said...

atoztoa,

same for me :-) . Thanks for commenting.

//Jadu

© Jadu Saikia www.UNIXCL.com