Usually at work you need to remove some outdated files, delete the batch method, but for certain file directory under retention want, you can use the following command:
For example, we want to delete specific files in another directory other than the directory 1 and 2 in the current directory path, find ./ \ (-path "./ directory 1" -o -path "./ directory 2" \) - prune -o -type f -name "* .txt" -exec rm -rf {} \;
Examples are as follows:
1, assume that a plurality of directories under the current directory, and the lower end of each directory has a .txt file, such as: test.txt
2, delete the test.txt file in the test2 and test3 directory, leaving the files in the directory test0 and test1
3, see the test.txt file
Results in line with expectations, a simple command, Mark it.