syntax error The source line is 1.
The error context is
BEGIN {FS=","}{ printf >>> % <<< s, $1 ; if ( $2=="" || $2==" ") print $2; else print substr($2,7,4)"-"substr($2,1,2) "-" substr($2,4,2), $3, $4, $5, $6 }
awk: The statement cannot be correctly parsed.
The source line is 1.
Maybe awk can't handle this. It also looks like I'd have to repeat the 'print' command for each 'else' or I won't get anything on a line where $2 is blank - which is way too tedious because my actual file has 35 columns with dates in various columns to reformat. Also, I'm not just reformatting dates but other fields as well in (i.e. if blank don't reformat) but this solution would help me to do the other columns.
Thanks. It worked but I may have to ditch awk and do a while read instead on all million+ lines and format it that way. I wanted to use awk since it's always been super fast but doesn't seem like it is possible for this situation. Oh well.
I wanted to help you find the problem with the awk script you were writing, but that does not mean it cannot be done with awk.
Would this be more in the direction?
Thank you so much! That's what I was looking for actually.
I thought we needed to show what we wrote to get help. My awk skill is apparently not very good but this works for me!
You're welcome! There are many ways of coding the same solution. My last suggestion is just a different approach. I was focussing on the error message, also because there was no input file specified in the first post. Come to think of it, if you only want to change dates around, sed might be more natural choice for the job..
Thank you. I'll save for when I have to reformat just the dates in a file. For this task, I had to reformat other fields at the same time if they exist like phone number, zip codes, etc., while printing out only needed columns, that's why I was looking at awk.
Thanks again!