0

Hi,

I am looping through some files, gathering information into an array during that loop. The array grows with the loop counter and at every point might be longer or shorter (more or less members in it)

so in order to reuse the array I need to drop all values in it, and I can't seem to find an easy way to do so (to loop through the array using its length and putting NULL into every position is a bit too much)

Example:

i=1
for tree in `ls -A /tmp/imagetrees/*.tree`
do
	for line in `cat $tree`
	do
		array[$i]=$line
		let i=$i+1
		
	done
	echo ${array[*]} > 
	i=1
	# need to reset array to NULL here, before reusing in the next loop
done

.tree file looks like this:
# cat /tmp/imagetrees/base33111.tree
base33111
base3311
base331
base33
base3
# cat /tmp/imagetrees/base33.tree
base33
base3

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by DimaYasny
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.