I am often given log files at work in .csv format to work with, normally extracting various fields. I then have to figure out the number of each field so that I can extract that field with cut or awk. Normally I just manually count the fields, based on the field separator. I would like to be able to take a line from the file and list the contents of each field along with the number of a field. Thus having the line of a file, such as:
apples,oranges,lemons,pears,peaches
I would like to see the output as:
1 apples
2 oranges
3 lemons
4 pears
5 peaches
I can then quickly see the columns that I need to extract.
I am aware of the "column" command, but often the files I have contain too many columns for this command to work.
Any help would be much appreciated