bash中,提取csv文件的一列 [英] bash, extract one column of a csv file

查看:1128
本文介绍了bash中,提取csv文件的一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个csv文件,是否有一个快速的庆典方式只打印出任何单一列的内容?它是安全的假设,每一行具有相同的列数,但各列的内容将具有不同的长度。

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.

推荐答案

您可以用awk这一点。更改'$ 2'到你想要的第n列。

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

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

这篇关于bash中,提取csv文件的一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆