Skip to main content
3 of 4
added 57 characters in body
Gilles Quénot
  • 36.6k
  • 7
  • 74
  • 97

Like this (any awk):

$ tac file | awk '
    BEGIN{FS=OFS=","}
    NR==1{split($0, a, FS);next}
    NR==2{for (i=1; i<=NF; i++)
        if ($i == 1) $i=a[++c]}
   1 # aka print
' 

Replace tac file by tail -r file on *BSD

Output

0,0,65,70,0,0,75,80,0,85,0,85,0,90
Gilles Quénot
  • 36.6k
  • 7
  • 74
  • 97