I have a text file delimited by commas, with three fields (no " marks).
I want to use awk to create a fourth field which is equal to the line number + field 1 + .txt
I've searched this forum and found the following
nawk -v OFS=';' '{print $0, FNR}' myFile
Which I've amended to change the ; to a , - and it works simply to append the line number at the end.
But when I amend it to the following, it won't accept that the commas is a delimeter and still thinks it should be a space;
nawk -v OFS=',' '{print $0, FNR "_" $1 ".txt"}' myFile
Field 2 has spaces, and it thinking that �1 is the whole of field 1 and the comma up to the first space in field 2.
Help! How can I get this awk to recognise that the comma is the delimter?
---------- Post updated at 01:03 PM ---------- Previous update was at 12:58 PM ----------
I've sorted this by amending OFS to FS - not sure what the difference is but it seemed to work