我正在构建一个脚本来一次下载所有 CodeCommit 存储库。
REPOS=$(aws codecommit list-repositories)
echo $REPOS | jq -r '.[]' | while read name ; do
git clone XXX
done
Run Code Online (Sandbox Code Playgroud)
在第一行中,我得到所有存储库 JSON,如下所示:
[
{
"repositoryName": "repo_a",
"repositoryId": "XXXXXX"
},
{
"repositoryName": "repo_b",
"repositoryId": "XXXXXX"
},
{
"repositoryName": "repo_c",
"repositoryId": "XXXXXX"
},
{
"repositoryName": "repo_d",
"repositoryId": "XXXXXX"
}
]
Run Code Online (Sandbox Code Playgroud)
我需要简单地迭代此 json,以获取属性repositoryName 并为每个存储库执行 git clone。
但在这个例子中,该命令jq -r '.[]'不起作用......这会在每次重复时返回整个 json。