This post will be teach you to find and delete the files and directories in Linux.
Directories:
1. Find Empty Directories:
find -empty command is used to find the empty directories in the current directory.
$ find . -type d -empty
2. Delete Empty Directories:
The following command is used to delete all empty directories in the current directory.
$ find . -type d -empty -exec rmdir {} \;
Files:
3. Find Empty Files:
find -empty command is used to find the empty files in the current directory.
$ find . -type f -empty
4.Counting of non-empty files:
The following command is used to find the number of non-empty files are located under the current directory?
$ find . -type f -not -empty | wc -l
Note: In all the above code "." will be replaced by the current directory name.
Comments (0)