I have a well structured comma separated file which has approximately 20 fields... some may have a few less. I would like to "merge" all of the fields $15 through NF into a single field. What I have written is working on my header line but blowing up on the subsequent lines... most of which start,,, with some empty fields. Here is my code so far:
#!/bin/awk -f
BEGIN {
FS=","
OFS=","
RS="\n"
ORS="\n"
}
{ #Loop through printing first 14 fields separated by commas
for (i=1; i<=NF; i++){
if (i<15){
printf("%s,", $i)
}
else{
printf("%s", $i)
}
}
}
#!/bin/awk -f
BEGIN {
FS=","
OFS=","
RS="\n"
ORS="\n"
}
{ #Loop through printing first 14 fields separated by commas
for (i=1; i<=NF; i++){
if (i<15){
printf("%s,", $i)
}
else{
printf("%s", $i)
}
}
}