Method of bulk deleting 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 |
This also allows you to delete a file of a 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 a 1k size file. (but be careful not to use the-size 1k, this gets the Occupy space 1k, not the file size 1k).
Query out all the empty folders
The code is as follows |
Copy Code |
Find-type D-empty |
deleting files
List the files that are searched
The code is as follows |
Copy Code |
Find. -name "Shuaige.txt"-exec ls {};
|
Bulk delete files that you have searched for
The code is as follows |
Copy Code |
Find. -name "Shuaige.txt"-exec rm-f {};
|
Prompt before deleting
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.-name There are also spaces
3.exec is a subsequent command, {} content represents the previously found file