Hello there,
This has confused the hell out of me for a while now, so here I am.
I have three arrays. Two with numbers and one with text. I'm trying to neatly print these three arrays out next to eachother, but here's where I get my problem.
The arrays look like this:
Code:
tsizes fsizes files
----- ----- -----
1462417408 735940608 File 1
578531636 367489024 File 2
578517728 367593472 File 3
578452724 366977024 File 4
578439568 367568896 File 5
578448102 365772800 File 6
578424864 365948928 File 7
578448934 369041408 File 8
578452528 367218688 File 9
578440336 367177728 File 10
578421354 366243840 File 11
578425152 367912960 File 12
578445224 367144960 File 13
578432682 367065088 File 14
578439098 367116288 File 15
578430258 367112192 File 16
577640484 367028224 File 17
578073694 367198208 File 18
578432472 367226880 File 19
578448496 367321088 File 20
578438178 367347712 File 21
Now I'm trying to print it out in pretty much the same way as you see it above, separated with " | ". Printing the out one by one is no problem, but when I want them next to each other the problems start.
Here was my first attempt:
Code:
for (( i=0; i< ${#tsizes[@]}; i++ ))
do
echo "${tsizes[$i]} | ${fsizes[$i]}$ | {ffiles[$i]}"
done
And here is the output from that:
Code:
| 735940608 | File 1
| 367489024 | File 2
| 367593472 | File 3
| 366977024 | File 4
| 367568896 | File 5
| 365772800 | File 6
| 365948928 | File 7
| 369041408 | File 8
| 367218688 | File 9
| 367177728 | File 10
| 366243840 | File 11
| 367912960 | File 12
| 367144960 | File 13
| 367065088 | File 14
| 367116288 | File 15
| 367112192 | File 16
| 367028224 | File 17
| 367198208 | File 18
| 367226880 | File 19
| 367321088 | File 20
| 367347712 | File 21
Ie, the first array isn't printed.
However, having the first array printed on its own in the loop does work. And when I try adding some random characters to print alone with the first array things get really weird:
Code:
for (( i=0; i< ${#tsizes[@]}; i++ ))
do
echo "${tsizes[$i]}test"
done
Output:
Code:
test417408
test31636
test17728
test52724
test39568
test48102
test24864
test48934
test52528
test40336
test21354
test25152
test45224
test32682
test39098
test30258
test40484
test73694
test32472
test48496
test38178
The word test is replacing the first four numbers!
Does anyone have an idea on why it would do that and how I can fix it?
Cheers!