K
K
ksvdon2015-01-14 12:11:41
bash
ksvdon, 2015-01-14 12:11:41

I fill the array element by element and lose the data that I filled in the "while read line", how to fix it?

/////SOLVED I
fill in some elements of the array

while read line
    do
  ggg=1
  for jfARRAY in 3 5 4
      do
    mline1=`echo $line | grep "statsu" | cut -d ';' -f $jfARRAY`
    MDERIVE1_1[$ggg]=`echo $mline1 | sed 's/[\.]\{0,1\}[0]*$//'`
    let ggg=$ggg+1
      done
    done <$forcornumb_1

later I fill other elements into an array no longer in a loop
MDERIVE1_1[0]=`echo "$toderive2_1" | grep "statsu" | cut -d ';' -f 1`
eota=4
for MYvalues in 2 10 11 12
    do
  MDERIVE1_1[$eota]=`echo "$toderive2_1" | grep "statsu" | cut -d ';' -f $MYvalues`
  let eota=$eota+1
    done

elements 0,4,5,6,7 I do NOT lose. But what was obtained in the cycle above (elements 1,2,3) disappear. I get a similar array further along the script, but there the entire (other) array is filled in the "while" loop... How not to lose elements? Can do something like export? Need some trick to add these 3 elements.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ksvdon, 2015-01-14
@ksvdon

There is a grep filter in the code. And when a string came across without the desired substring, everything was overwritten with emptiness. Decided with a different filter. (Removed grep, put "case line in / esac"). Thus, the "left" substring does not reach the entry at all and does not overwrite the array with emptiness.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question