How to bulk delete empty files (Files of size equal to 0) under Linux
The code is as follows |
Copy Code |
Find. -name "*"-type f-size 0c | Xargs-n 1 rm-f |
You can also delete a file of the specified size, as long as you modify the corresponding-size parameter, for example:
The code is as follows |
Copy Code |
Find. -name "*"-type f-size 1024c | Xargs-n 1 rm-f |
is to delete files of 1k size. (but be careful not to use-size 1k, this gets to occupy space 1k, not file size 1k).
Query out all empty folders
The code is as follows |
Copy Code |
Find-type D-empty |
deleting files
List the files you have searched for
The code is as follows |
Copy Code |
Find. -name "Shuaige.txt"-exec ls {}; |
Delete a searched file in bulk
The code is as follows |
Copy Code |
Find. -name "Shuaige.txt"-exec rm-f {}; |
Prompt before deletion
The code is as follows |
Copy Code |
Find. -name "Shuaige.txt"-ok rm-rf {}; |
Delete the files under all the test folders under the current directory
The code is as follows |
Copy Code |
Find. -name "Test"-type d-exec rm-rf {}; |
Delete all the. svn files under the folder
The code is as follows |
Copy Code |
Find. -name '. SVN '-exec rm-rf {}; |
Note:
1.{} and there is a space between
2.find. There are also spaces between-name
3.exec is a follow-up command, and the contents of {} represent the files found earlier
Find bulk Delete empty files and empty folders in Linux