我有两个变量,如下所示:
a=10 20 30 40
b=1000 2000 3000 4000
我需要所需的输出,如下所示:
10|1000
20|2000
30|3000
40|4000
我怎样才能做到这一点?
a1=($a) # if a & b are already arrays, you don't need this step
b1=($b) # directly go to the for loop. use a,b instead of a1,b1
for((i=0;i<${#b1[@]};i++))
do
echo "${a1[$i]}|${b1[$i]}"
done
应该这样做.
输出
10|1000
20|2000
30|3000
40|4000