How to extract one column of a csv file

user788171 picture user788171 · Oct 26, 2013 · Viewed 156.5k times · Source

If I have a csv file, is there a quick bash way to print out the contents of only any single column? It is safe to assume that each row has the same number of columns, but each column's content would have different length.

Answer

synthesizerpatel picture synthesizerpatel · Oct 26, 2013

You could use awk for this. Change '$2' to the nth column you want.

awk -F "\"*,\"*" '{print $2}' textfile.csv