Printing column separated by comma using Awk command line

awkcsv

I have a problem here. I have to print a column in a text file using awk. However, the columns are not separated by spaces at all, only using a single comma. Looks something like this:

column1,column2,column3,column4,column5,column6

How would I print out 3rd column using awk?

Best Answer

Try:

awk -F',' '{print $3}' myfile.txt

Here in -F you are saying to awk that use , as the field separator.

Related Topic