40 lines
		
	
	
		
			1023 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1023 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | ||
| 
 | ||
| # 检查参数
 | ||
| if [ "$#" -ne 1 ]; then
 | ||
|     echo "Usage: $0 <directory>"
 | ||
|     echo "Example: $0 /path/to/search"
 | ||
|     exit 1
 | ||
| fi
 | ||
| 
 | ||
| # 检查目录是否存在
 | ||
| if [ ! -d "$1" ]; then
 | ||
|     echo "Error: Directory '$1' does not exist."
 | ||
|     exit 1
 | ||
| fi
 | ||
| 
 | ||
| # 递归遍历并删除文件
 | ||
| find "$1" -type d -name "tool" | while read -r tool_dir; do
 | ||
|     # 在tool目录下查找src目录
 | ||
|     src_dir="$tool_dir/src"
 | ||
|     if [ -d "$src_dir" ]; then
 | ||
|         # 删除src目录下的所有文件
 | ||
|         find "$src_dir" -type f -delete
 | ||
|         echo "Deleted all files in '$src_dir'"
 | ||
|     else
 | ||
|         echo "No 'src' directory found in '$tool_dir'"
 | ||
|     fi
 | ||
| 
 | ||
|     # 检查CMakeLists.txt文件是否存在,然后删除
 | ||
|     cmake_file="$tool_dir/CMakeLists.txt"
 | ||
|     if [ -f "$cmake_file" ]; then
 | ||
|         rm "$cmake_file"
 | ||
|         if [ $? -eq 0 ]; then
 | ||
|             echo "Deleted 'CMakeLists.txt' in '$tool_dir'"
 | ||
|         else
 | ||
|             echo "Error deleting 'CMakeLists.txt' in '$tool_dir'"
 | ||
|         fi
 | ||
|     fi
 | ||
| done
 | ||
| 
 | ||
| echo "Operation completed." | 
