Answer the question
In order to leave comments, you need to log in
Why does the loop break unexpectedly?
There is a script:
#!/bin/bash
file="/tmp/test.csv" # 879314 strok
for ((;;))
do
index=0
while read line; do
array[$index]="$line"
index=$(($index+1))
done < $file
for ((a=0; a < ${#array[*]}; a++))
do
echo "${array[$a]}" >> /tmp/test-cycle.csv
done
echo > /tmp/test-cycle.csv
done
Answer the question
In order to leave comments, you need to log in
I suspect you're just hitting the memory limit that bash allocates for an array.
For example, for ksh93 it is ~4 MB by default. Offhand what is the limitation in bash and how to look at it I will not say.
But in this script, why would you want to create an array at all? You can immediately output to a file
while read line; do
echo "$line" >> /tmp/test-cycle.csv
done < $file
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question