EG/count_code.sh
2025-10-24 14:30:34 +08:00

17 lines
530 B
Bash
Executable File

#!/bin/bash
# 清空或创建结果文件
echo "" > results.txt
# 读取一级目录列表并逐个统计代码行数
while read dir; do
if [ -d "$dir" ] && [ "$(dirname "$dir")" = "." ]; then
echo "Processing $dir..."
echo "统计的是文件夹: $dir" >> results.txt
# 使用 cloc 统计代码行数,并将结果追加到文件中
cloc "$dir" >> results.txt
echo "----------------------------------------" >> results.txt
fi
done < directories.txt
echo "统计完成,结果已保存到 results.txt"