#!/usr/bin/env bash
for x in $(ls git-report/)
do
repo_name=${x/.txt/}
while IFS=' ' read -r col1 col2;
do
pushd "backend-projects/${repo_name}"
git diff --numstat ${col2}..master | awk 'NF==3 {plus+=$2} END {print plus}' | cat >> /tmp/repos/${repo_name}.txt
git diff --numstat ${col2}..master | awk 'NF==3 {minus+=$1} END {print minus}' | cat >> /tmp/repos/${repo_name}.txt
cat /tmp/repos/${repo_name}.txt >> /tmp/script
popd
echo "# ----------- "
done < "git-report/$x"
done
因此,我有两个目录,git-report
和单独的文本文件,其中包含每个存储库的所有未合并分支名称。第二个backend-projects
包含所有存储库。
手动执行这些命令会将文件写入文件,但是在运行bash脚本时失败。我在做什么错了?