Delete Files Except Ones With Certain Extension
by Kyle on
find . ! -name "*.php" -exec rm -f {} \;
Delete Zero Size Files
by Kyle on
This will delete all files in the current directory that have a size of zero.
find . -type f -size 0k -exec rm {} \; | awk '{ print $8 }'
Recursively Delete .DS_Store Files
by Kyle on
find . -name *.DS_Store -type f -exec rm {} \;
Recursively Find And Delete Files
by Kyle on
This command will recursively search for a file and remove it.
For example, if you wanted to delete all index.html files, you would do this:
find ./ -name 'index.html' -exec rm '{}' ';' -print
If you wanted to remove all files ending in .html, you would do this:
find ./ -name '*.html' -exec rm '{}' ';' -print