title: awk command to split nth field
body: <p>I am learning AWK and was trying some exercises on built-in string functions.</p>
  
  <p>Here's my exercise:</p>
  
  <p>I have a file containing as below</p>
  
  <pre><code>RecordType:83    
  1,2,3,a|x|y|z,4,5
  </code></pre>
  
  <p>And my desired output is as below:</p>
  
  <pre><code>RecordType:83       
  1,2,3,a,4,5         
  1,0,0,x,4,5         
  1,0,0,y,4,5       
  1,0,0,z,4,5
  </code></pre>
  
  <p>I wrote an awk command for the above output.</p>
  
  <pre><code>awk -F',' '$1 ~ /RecordType:83/{print $0}
  
  $1 == 1{
  
  split($4,splt,"|")
  
  for(i in splt)
  
  { 
  
  if(i==1) 
  
  print $1,$2,$3,splt[i],$5,$6 
  
  else 
  
  print $1,0,0,splt[i],$5,$6
  
  } 
  
  }' OFS=, file_name
  </code></pre>
  
  <p>The above command looks so clumsy. Is there any way minimizing the command?</p>
  
  <p>Thanks in advance</p>