Basic Linux Tutorials Introduction to the command for bulk delete files and empty file deletions in Linux systems
Linux Data Delete file or directory commands below rm (remove) :
Linux Training Feature Description: Delete files or directories.
Syntax:RM [-dfirv][--help][--version][file or directory ...]
Additional Note: The Execute RM instruction can delete the file or directory, if you want to delete the directory must add the parameter "-r", otherwise the default will only delete the file.
Parameters
-D or--directory delete the hard connection data for the directory that you want to delete directly by deleting the directory by 0.
-F or--force forces the deletion of files or directories.
-I or--interactive to ask the user before deleting both files or directories.
-R or-R or--recursive recursively handles all files and subdirectories under the specified directory.
-V or--verbose shows the instruction execution process.
--help online Help.
How to bulk delete empty files (Files of size equal to 0) under Linux
The code is as follows
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
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).
If you just delete the folder or the name of the connection, you can change the -type parameters, specific details see man find
Delete N days ago File
Linux Bulk Delete files by time (delete n days ago file)
The code is as follows
find/opt/oracle/admin/ccxe/bdump/-mtime +10-name "* *"-exec RM-RF {};
/opt/oracle/admin/ccxe/bdump/: Any directory that you want to clean up
-mtime: Standard statement notation
+10: Find the file 10 days ago, where the number represents the number of days, +30 means to find the file 30 days ago
"*. *": The type of data you want to find, "*.jpg" means looking for all files with the extension jpg, "*" means finding all files
-exec: Fixed notation
RM-RF: Forcibly deleting files, including directories
{} ; : fixed notation, pair of curly braces + space +/+;
Delete Files completely
sometimes we have to completely delete some files, you can use the shred command to implement, Shred is a part of the coreutils, so Linux basically will have this command.
Shred how to delete files completely:
The code is as follows
$ shred-u File
Shred will overwrite the node and data block where the file resides with some random content, and delete the file (-u parameter).
If you want to clear a bit more thoroughly you can add the-z parameter, which means to fill with random data, and then fill it with 0.
The code is as follows
$ shred-u-Z File
In addition shred can also clear the entire partition or disk, such as to completely clear the contents of the/DEV/SDB1 partition can be:
$ SHRED/DEV/SDB1 (note do not add-u parameter)
Detailed parameters of the shred:
-F,--force Change permissions allow write (if necessary)
-N,--iterations=n rewrite n times, default is 3 times
--random-source=file reading data from a specified file
-S,--size=n the file to a fixed size (suffixes such as K, M, C, etc. can be used)
-U,--remove truncate and remove files after rewriting
-V,--verbose show progress
-Z,--zero-add with 0 coverage data
Help Display Help
–version displaying version information
Description of the command for bulk delete files and empty file deletions in Linux base Linux systems