Q:

If column 2 is empty, then assign column 4's value to column 2 and column 5's value to column 3

I have a file 
Field1 Field2 Field3 Field4 Field5
a1     a2     a3     a4     a5
b1                   b4     b5
c1     c2     c3     c4     c5
d1                   d4     d5
e1                   e4     e5

I would like to copy Field 4's value to Field 2 and Field 5's value to Field 3 if Field 2 is empty.
So the expected outcome should be  
Field1 Field2 Field3 Field4 Field5
a1     a2     a3     a4     a5
b1     b4     b5     b4     b5
c1     c2     c3     c4     c5
d1     d4     d5     d4     d5
e1     e4     e5     e4     e5

What I have currently is this 
awk -F, 'BEGIN {
   for (i = 1; i <= n; ++i) {
      if ($2=="") {$2=$7}
  print
   }
}' File > FileA 

But it doesn't work at all.... Any help would be appreciated! Thanks 
edit1:
both input and output file are comma separated, so the raw data will be something like 
input file 
a1,a2,a3,a4,a5
b1,,,b4,b5
c1,c2,c3,c4,c5
d1,,,d4,d5
e1,,,e4,e5

Output file
a1,a2,a3,a4,a5
b1,b4,b5,b4,b5
c1,c2,c3,c4,c5
d1,d4,d5,d4,d5
e1,e4,e5,e4,e5

A:

awk 'BEGIN{FS=OFS=","} $2=="" {$2=$4; $3=$5}1' file

Input from file:

a1,a2,a3,a4,a5
b1,,,b4,b5
c1,c2,c3,c4,c5
d1,,,d4,d5
e1,,,e4,e5

Output to stdout:

a1,a2,a3,a4,a5  
b1,b4,b5,b4,b5
c1,c2,c3,c4,c5
d1,d4,d5,d4,d5
e1,e4,e5,e4,e5

See: 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR

