In centos, a super-convenient, but extremely tragic command combination, find + rm, believe that friends who have made mistakes can see this command in their hearts, query and delete files based on a certain condition. Example: 1. in linux, find and delete the file a year ago. how can I write a command? # Find/-ctime in centos, a super-convenient but extremely tragic command combination find + rm
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!