-2
我有像下面两个变量:如何在Linux/unix中使用管道追加两个变量?
A = 10 20 30 40
B = 1000 2000 3000 4000
我所需要的期望的输出象下面这样:
10 | 1000
20 | 2000
30 | 3000
40 | 4000
我该如何做到这一点?
我有像下面两个变量:如何在Linux/unix中使用管道追加两个变量?
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
请看看[编辑的帮助(http://stackoverflow.com/editing-help)。 – Cyrus
你能显示一些代码吗?像你的变数一样;他们是'bash'变量吗? – totoro