awk或sed CSV文件操作 [英] awk or sed CSV file manipulation

查看:101
本文介绍了awk或sed CSV文件操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"a004-1b","North","at006754"
"a004-1c","south","atytgh0"
"a004-1d","east","atrthh"
"a010-1a","midwest","atyu"
"a010-1b","south","rfg67"

我要打印第一列和第二列而没有任何多余的字符,我想消除所有字符("和第三列).

I want to print the first column and the second column without any extra character I want eliminate all ("", and the third column) Thanks in advance

推荐答案

awk -F'^"|","|"$' '{print $2,$3}' ./infile.csv

上面的脚本甚至可以处理带有双引号或逗号的字段.唯一的缺点(如果可以这样称呼)是第一个字段开始于$2

The above script will even handle fields that have embedded double quotes or commas. The only downside (if you can call it that) is that the first field starts at $2

$ awk -F'^"|","|"$' '{print $2,$3}' ./infile.csv
a004-1b North

a004-1c south

a010-1a midwest

a010-1b south

这篇关于awk或sed CSV文件操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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