I've got this problem, if I modify an array in the loop and print it, everything is fine as long as I stay in the loop. But, when I print it outside the loop, nothing happens... How can I solve this problem?
Here I prepared a sample for you to see my problem;
zgrw@Rain:~$ cat test
asd
123
13
1234
zgrw@Rain:~$ cat test.sh
#!/bin/bash
declare -a asd
c=0
cat test | while read line; do
asd[$c]=$line
echo ${asd[@]}
((c++))
done
echo "I wish you here"
echo ${asd[@]}
Output is;
zgrw@Rain:~$ ./test.sh
asd
asd 123
asd 123 13
asd 123 13 1234
I wish you here
zgrw@Rain:~$
