AWK/BASH:如何从具有已知字段范围的文件中删除重复行?
我想知道是否有一种方法可以使用 bash/awk 根据已知的字段范围删除重复的行。例如:
Easy Going USA:22 May 1926
Easy Going Gordon USA:6 August 1925
Easy Life USA:20 May 1944
Easy Listening USA:14 January 2002
Easy Listening USA:10 October 2002
Easy Listening USA:27 January 2004
Easy Living USA:7 July 1937
Easy Living USA:16 July 1937
Easy Living USA:4 September 2009
我想删除重复的移动标题。电影标题始终从 $1 到 $(NF-3)。理想情况下,我想坚持第一次出现(最早的日期),但如果不可能,那就没关系。
谢谢,
托梅克
I was wondering if there was a way to use bash/awk to remove duplicate rows based on a known field range. For example:
Easy Going USA:22 May 1926
Easy Going Gordon USA:6 August 1925
Easy Life USA:20 May 1944
Easy Listening USA:14 January 2002
Easy Listening USA:10 October 2002
Easy Listening USA:27 January 2004
Easy Living USA:7 July 1937
Easy Living USA:16 July 1937
Easy Living USA:4 September 2009
I would like to remove duplicate move titles. The movie title will always be from $1 through $(NF-3). Ideally I would like to stick with the first occurrence (earliest date), but if that's not possible then it doesn't matter.
Thanks,
Tomek
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
输出
output
这不会保留原始的行顺序。您可能想要对输出进行
排序
。That does not preserve the original line ordering. You might want to
sort
the output.这可能是一个快速答案
This could be a quick answer