Hi - I don't understand why the following script isn't working. I want to read the contents of a while loop into an array, but it looks like the array is destroyed once the while loop is finished. Can anybody help?
someFile:
PC_1 wf_test1 Test
PC_2 wf_test2 Test
PC_3 wf_test3 Test
Script:
cat someFile |
while read l; do
echo "array[${#array
[*]}]=\"$l\""
array[${#array
[*]}]="$l"
done
for ((i=0;i<${#array
[*]};i++)); do
echo ${array}
done
#!/bin/bash
while read l; do
echo "array[${#array
[*]}]=\"$l\""
array[${#array
[*]}]="$l"
done < someFile
for ((i=0;i<${#array
[*]};i++)); do
echo ${array}
done