Question : Sed in a while read loop wont replace pattern stored in a variable

I am using sed to match patterns in csv File. The csv file is as follows:

 "VALUE";"VALUE";"VALUE";"VALUE";.......

to replace a value i use:

sed '2,4621s/[^;]*;/"'"$VALUE"'";/11' < file.csv

this works pretty fine if there is only one value given lets say:

VALUE=TEST

sed '2,4621s/[^;]*;/"'"$VALUE"'";/11' < file.csv

this replaces the 11th VALUE in every line from 2 to 4621 with TEST

but now i have a file2  where other values are stored. It's stored in this format

VALUE
VALUE
VALUE
VALUE


Now i want to read the values from the file above and replace it in the csv file

i tried this:

while read VALUE
do


        V=`sed '2,4621s/[^;]*;/"'"$VALUE"'";/11' < file.csv`

        echo $V > new_file.csv


done
but somehow this outputs only empty space on the place where the values of file2 should be inserted


 "VALUE";"VALUE";"VALUE";"EMPTY SPACE";"VALUE";.......

I tried many things and played around but without luck

i am using ubuntu hardy heron....

thx alot


 

Answer : Sed in a while read loop wont replace pattern stored in a variable


while read VALUE
do

        cat file.csv | head -$COUNTER | tail -1 | sed  's/[^;]*;/"'"$VALUE"'"';/11;' >> new_file.csv


        let COUNTER=COUNTER+1

done
maybe not the best solution but it works for me

Random Solutions  
 
programming4us programming4us