Files
aiagent/backend/scripts/count_extensions.sh
renjianbo beff3fac8d fix: delete agent 500 error + dynamic personality + deployment guide
- Fix delete agent 500: clean up FK records (agent_llm_logs, permissions,
  schedules, executions, team_members) and unbind goals/tasks before delete
- Remove hardcoded personality templates in Android, replace with dynamic
  system prompt generation from name + description
- Set promptSectionsEnabled=false to bypass PromptComposer for personality
- Add Tencent Cloud Linux deployment guide (Docker Compose)
- Accumulated backend service updates, frontend UI fixes, Android app changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-29 01:17:21 +08:00

98 lines
2.2 KiB
Bash

#!/bin/bash
# count_extensions.sh - 统计当前目录下每种文件扩展名的数量
# 用法: ./count_extensions.sh [目录路径] [-r|--recursive]
set -euo pipefail
# 默认值
TARGET_DIR="."
RECURSIVE=false
# 解析参数
while [[ $# -gt 0 ]]; do
case "$1" in
-r|--recursive)
RECURSIVE=true
shift
;;
-h|--help)
echo "用法: $0 [目录路径] [-r|--recursive]"
echo ""
echo "选项:"
echo " 目录路径 要统计的目录(默认当前目录)"
echo " -r, --recursive 递归统计子目录"
echo " -h, --help 显示帮助信息"
exit 0
;;
-*)
echo "错误: 未知选项 $1" >&2
exit 1
;;
*)
TARGET_DIR="$1"
shift
;;
esac
done
if [ ! -d "$TARGET_DIR" ]; then
echo "错误: 目录 '$TARGET_DIR' 不存在" >&2
exit 1
fi
echo "正在统计: $TARGET_DIR"
echo "-------------------------"
# 统计文件扩展名
if [ "$RECURSIVE" = true ]; then
# 递归方式 - 包含子目录
result=$(find "$TARGET_DIR" -type f | awk -F. '
NF > 1 {
ext = tolower($NF)
count[ext]++
}
NF == 1 {
count["(无扩展名)"]++
}
END {
for (ext in count) {
printf "%-20s %d\n", ext, count[ext]
}
}
')
else
# 仅当前目录 - 不进入子目录(使用 -maxdepth 1 兼容性更好的写法)
result=$(find "$TARGET_DIR" -maxdepth 1 -type f | awk -F. '
NF > 1 {
ext = tolower($NF)
count[ext]++
}
NF == 1 {
count["(无扩展名)"]++
}
END {
for (ext in count) {
printf "%-20s %d\n", ext, count[ext]
}
}
')
fi
# 输出结果
if [ -z "$result" ]; then
echo "(没有找到文件)"
exit 0
fi
echo "$result" | sort -k2 -nr | awk '
BEGIN { total = 0 }
{
printf " %-20s %s\n", $1, $2
total += $2
}
END {
print "-------------------------"
printf " 合计: %d 个文件\n", total
}
'