Find + rm command combination in CentOS
Find + rm, a super-convenient but extremely tragic command combination in centos
I believe that my friends who have made mistakes can see this command in their hearts ......
The find + rm combination queries files based on certain conditions and deletes them.
Example:
1. in linux, find and delete the file a year ago. How can I write a command?
# Find/-ctime + 365-exec rm-rf {}\;
Remember:
The first/Represents the root directory. Do not write this. Write the directory you need to find. Remember, I am here for convenience.
It must be followed by a; No. Otherwise it won't work. This is the end of the syntax.
2. in linux, find and delete all PHP files under a file. How can I write a command?
# Find./-type f-name "*. php"-exec rm-f {}\;
A very useful command combination, but you need to use it carefully. Don't regret it for life!