hunting/tools/shell/delete_sdk_code.sh
2024-06-15 08:39:16 +08:00

46 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 查找目录列表
search_dirs=("../../middleware" "../../application" "../../utils")
# search_dirs=("../../test-utils")
# 保留目录列表
# preserve_dirs=("../../test-utils/LinuxApi" "../../test-utils/ConfigBase")
preserve_dirs=(
"../../test-utils/Log")
# 遍历查找目录
for search_dir in "${search_dirs[@]}"; do
echo "正在处理目录: $search_dir"
# 使用find命令遍历目录并删除文件
find "$search_dir" -type d | while read -r dir; do
# 检查目录是否在保留列表中
is_preserve=false
for preserve_dir in "${preserve_dirs[@]}"; do
if [[ "$dir" == *"$preserve_dir"* ]]; then
is_preserve=true
break
fi
done
# 如果目录不在保留列表中则删除src目录和CMakeLists.txt
if [[ $is_preserve == false ]]; then
src_dir="$dir/src"
cmake_file="$dir/CMakeLists.txt"
# 如果src目录存在则删除它
if [[ -d "$src_dir" ]]; then
echo "删除目录: $src_dir"
rm -rf "$src_dir"
# 如果CMakeLists.txt文件存在则删除它
if [[ -f "$cmake_file" ]]; then
echo "删除文件: $cmake_file"
rm "$cmake_file"
fi
fi
fi
done
done
echo "处理完成"