Requirements: I want to delete log log files in batches under the Linux system, because there are too many modules, there are many logs, and under different directories, we can output the path of these logs through the find command, how to delete them in batches?
The first way
To batch delete files of the same format in a multi-level directory in Linux, you can use the find + exec command combination:
For example, in the deleted old directory, in all subdirectories, the file method with the suffix .l is:
find old -type f -name "*.l" -exec rm -f {} \;
Illustrate:
•old: The starting directory to be found, search for the subdirectory under it
•-type f : The file type is a normal file If the target file is a directory, use -type d
•-name "*.l" : means that the file name matches "*.l", and double quotation marks cannot be missing!
•rm -f {} : When deleting, {} indicates the found file without prompting
ps : between {} and \Spaces are required
The second way
Use the xargs parameter
find . -name "._*" | xargs rm -rf
|