【发布时间】:2019-09-21 11:10:46
【问题描述】:
我想迭代 3 个数组应该得到如下输出,有人可以帮忙吗?
~ cat new.csv
team1,team2,team3
CPMSCF,cpmscf,pipelineoperator
CPOCNCF,cpocncf,pipelineoperator
team1="$(cat new.csv | cut -d, -f1 | tail -n +2)"
team2=$(cat new.csv | cut -d, -f2 | tail -n +2)
team3=$(cat new.csv | cut -d, -f3 | tail -n +2)
for index in ${!team1[*]}; do
echo "${team1[$index]}:${team2[$index]}:${team3[$index]}"
done
输出我得到的是:
CPMSCF
CPOCNCF:cpmscf
cpocncf:pipelineoperator
pipelineoperator
但应该是
CPMSCF:cpmscf:pipelineoperator
CPOCNCF:cpocncf:pipelineoperator
【问题讨论】:
-
你的问题对我来说不是很清楚,因为运行你的脚本会得到你想要的相同的预期输出。
-
对不起,我的错误。我用更多细节更新了问题