I am trying to process a log file using awk. The log file lines resemble the following:
timestamp devicename data data data timestamp devicename data data timestamp devicename data data data .....
I would like to create a csv file that resembles the following
timestamp,devicename,all other data
This would be pretty easy if the data following the device name always contained the same number of delimited values, which it does not unfortunately. How should I go about using awk to create a CSV file where the timestamp is first in the csv file, the devicename is second, and all other data fields are in the third column?
I was looking around online and most people suggested simply setting the first one or two fields to “” and then printing out everything at once (to get the range of fields), but that would not work in that case as I still want to use the timestamp and devicename in the csv file.