使用 awk 处理文本
我正在尝试使用 awk 处理 csv 文件。我的 csv 文件中有五行。我想要我的第 1 栏和第 1 栏第 3 列组合起来是唯一的。使用 awk 我写了
awk -F "," '{print $1,",",$2,","$3,",",$4,",",$5}' A.csv|sort|uniq > ;B.csv
此代码的作用是获得一个由 1 到 5 行组合而成的唯一行。我希望我的其他列位于最终的 csv 文件中,但仅按第一列和第三列进行排序和 uniq。
I am trying to process a csv file using awk. I have five rows in my csv file. I want my column 1 & column 3 combined to be unique. Using awk I wrote
awk -F "," '{print $1,",",$2,","$3,",",$4,",",$5}' A.csv|sort|uniq >B.csv
What this code does is to have a unique row with 1 to 5 rows combined. I want my other columns to be in final csv file but sorted and uniq only by 1st and 3rd columns.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您想保留至少一个重复行
如果您不想保留重复行
assuming you want to keep at least one of the duplicate lines
If you don't want to keep duplicate lines