如何从一个CSV文件中的每一行的第一列?

问题描述:

如何获得在输入​​CSV文件和输出每行的第一列到一个新的文件吗?我使用 AWK 但不知道如何。

How do get the first column of every line in an input CSV file and output to a new file? I am thinking using awk but not sure how.

试试这个:

 awk -F"," '{print $1}' data.txt

这将文件中的每个输入行分割的data.txt 进入基于不同的领域,字符(如与 -F )指定,第一个字段(列)打印到标准输出。

It will split each input line in the file data.txt into different fields based on , character (as specified with the -F) and print the first field (column) to stdout.